pm21-dragon/exercises/release/exercise-07/3__plot_csv.ipynb
2024-11-25 08:20:05 +01:00

2.4 KiB

None <html> <head> </head>

Create a standalone Python program

The instructions for this exercise are in this Jupyter notebook, but to successfully complete the exercise, you need to write a plain Python .py file called plot_pcr_data.py that runs from the command line. Write your program so that when you run it like this:

python plot_pcr_data.py pcr_sample_1.csv

It will read load the CSV file named pcr_sample_1.csv and save a plot called pcr_sample_1.csv.png. This data file is the result of a real-time PCR experiment in a 6 well plate. The plot should plot number of cycles on the X axis and fluorescence intensity on the Y axis. There should be a line for the data from each well in the experiment.

Hints:

  • Remember that you can get the command-line arguments to a python program by importing the sys module and accessing the sys.argv variable, which is a list of strings. So the filename with the data is provided as a command-line argument to your python program.
  • Read the CSV data from the provided filename using Pandas read_csv() function.
  • Plot the results with seaborn's lineplot() function.
  • Save this figure (with matplotlib.pylot's savefig()) to a file with the name equal to the original file name with .png appended to it (e.g. for the above example with pcr_sample_1.csv as input, save the figure to pcr_sample_1.csv.png).

When you are done with your program plot_pcr_data.py, upload it to the directory for this exercise. I will run it with a new CSV data file from a different PCR experiments to check that it works.

With pcr_sample_1.csv, your plot should look like this:

pcr_results.png

</html>