0

I'm using Python and have never used it before to draw a plot and was wondering if there's a way to do the following. I have a file containing a column with percents (of DNA methylation data). I would like to plot the distribution frequency (perhaps using bins of 10) to display the data. Is there any way to do this in python.

user2165857
  • 2,530
  • 7
  • 27
  • 39
  • you dont describe your input very well ... are you at least able to get a numerical list of percentages from the file? what have you tried so far. if your question is "Can I do this in python?" the answer is yes. – Joran Beasley May 24 '13 at 20:41

2 Answers2

1

Matplotlib is the tool that you want to explore. Here is a nice tutorial, try working through the examples in that tutorial. http://bespokeblog.wordpress.com/2011/07/11/basic-data-plotting-with-matplotlib-part-3-histograms/

The tutorial includes installation of matplotlib in ubuntu. If you are using windows, you should download the installer from http://matplotlib.org/downloads.html

yardsale8
  • 940
  • 9
  • 15
0

If your RAW methylation data came in the form of .idat files (Illumina uses this), look at the methylprep python package (and its associated methylcheck package for doing plots).

For methylation data, most people plot samples as a beta distribution or m_value plot showing the percent methylation for each probe (but actually a fraction from 0 to 1, not actually a percent).

Use would be something like this:

CLI: `python -m methylprep process -d <folder_path_of_idats> --all`
python:
>>>import methylcheck
>>>df = methylcheck.load(<path>) # creates a pandas dataframe of all samples in the folder you are in, or path specified.
>>>methylcheck.sample_plot(df)

example of plot produced in jupyter notebook below

enter image description here

Marc Maxmeister
  • 4,191
  • 4
  • 40
  • 54