plot_macs_cutoff_analysis.py 985 B

123456789101112131415161718192021222324252627282930313233343536
  1. import sys
  2. import pandas as pd
  3. import matplotlib.pyplot as plt
  4. def plot_data(input_file, output_file):
  5. # Read data from the file
  6. df = pd.read_csv(input_file, sep="\t")
  7. # Plotting the data
  8. fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))
  9. # Plotting npeaks vs qscore
  10. ax1.plot(df["qscore"], df["npeaks"], marker='o', color='b')
  11. ax1.set_title("npeaks vs qscore")
  12. ax1.set_xlabel("qscore")
  13. ax1.set_ylabel("npeaks")
  14. # Plotting avelpeak vs qscore
  15. ax2.plot(df["qscore"], df["avelpeak"], marker='o', color='r')
  16. ax2.set_title("avelpeak vs qscore")
  17. ax2.set_xlabel("qscore")
  18. ax2.set_ylabel("avelpeak")
  19. plt.tight_layout()
  20. # Save the plot as a PDF
  21. plt.savefig(output_file)
  22. if __name__ == "__main__":
  23. if len(sys.argv) != 3:
  24. print("Usage: python script.py input_file.txt output_file.pdf")
  25. else:
  26. input_file = sys.argv[1]
  27. output_file = sys.argv[2]
  28. plot_data(input_file, output_file)