pm21-dragon/exercises/release/exercise-07/3__plot_csv.ipynb

53 lines
2.4 KiB
Plaintext
Raw Normal View History

2024-11-25 02:20:05 -05:00
{
"cells": [
{
"cell_type": "markdown",
"id": "0a7b652b-7846-464c-acf3-6629ba66a192",
"metadata": {},
"source": [
"# Create a standalone Python program\n",
"\n",
"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:\n",
"\n",
" python plot_pcr_data.py pcr_sample_1.csv\n",
"\n",
"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](https://en.wikipedia.org/wiki/Real-time_polymerase_chain_reaction) 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.\n",
"\n",
"Hints:\n",
"\n",
"- 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.\n",
"- Read the CSV data from the provided filename using Pandas `read_csv()` function.\n",
"- Plot the results with seaborn's `lineplot()` function.\n",
"- 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`).\n",
"\n",
"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.\n",
"\n",
"With `pcr_sample_1.csv`, your plot should look like this:\n",
"\n",
"![pcr_results.png](pcr_results.png)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}