0% found this document useful (0 votes)
3 views21 pages

Advanced Python Data Analysis Techniques

The document outlines an intermediate/advanced Python training session led by Michael Weinstein, covering topics such as data structures, Numpy, Pandas, Matplotlib, and Scipy. It emphasizes the use of dataframes for data manipulation, particularly in analyzing base frequency from SAM files. The session includes practical coding exercises and discussions on data representation and visualization techniques.

Uploaded by

ymaliki903
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views21 pages

Advanced Python Data Analysis Techniques

The document outlines an intermediate/advanced Python training session led by Michael Weinstein, covering topics such as data structures, Numpy, Pandas, Matplotlib, and Scipy. It emphasizes the use of dataframes for data manipulation, particularly in analyzing base frequency from SAM files. The session includes practical coding exercises and discussions on data representation and visualization techniques.

Uploaded by

ymaliki903
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Intermediate/Advanced

Python
Michael Weinstein
(Day 3)
Topics
› Review of basic data structures
› Accessing and working with objects in python
› Numpy
› Pandas
– What are dataframes?
– Sample column counting operation
– Test, refine, test, refine, test, refine to get the data structure we want
– Extracting a column
› Matplotlib
– Making a simple line plot
› Scipy
Next goal: Analyze base frequency at each
position in the first 50 bases
› Need to iterate over sam file again
› Need to grab the first 50 bases of each read
› Need to turn the string into a list
› Need to move the data to a pandas dataframe
– This is a more flexible structure for holding heterogenous data
– Not as efficient as a numpy array, but still very fast
– Very similar to dataframes in R language
› Need to count base occurrences in each column
› New file: [Link]
How to think of a dataframe?
How to count letters in a column?
Some test code
Data looks
almost right,
except we need
it transposed (we
want position to
be the columns).
How to transpose
Testing our data structure
Looks good!
Testing our data structure

Test code (can be removed after it works)


We just need to return the transposed dataframe
Replace the box contents with:
return [Link]()
Testing out our next data structure
Testing out the data structure
Transposing and extracting a column…
This is what we want to see
Finalize the function and call
Important question:
How to represent our data
› Class participation time: Start making suggestions

› Don’t cheat here if you’ve looked ahead

› More than one right answer


character description
'-' solid line style
Pyplot marker codes '--' dashed line style

(Don’t worry about memorizing) '-.'


':'
dash-dot line style
dotted line style
Keep a reference if you use '.'
','
point marker
pixel marker
these often 'o' circle marker
'v' triangle_down marker
'^' triangle_up marker
'<' triangle_left marker
character color '>' triangle_right marker
‘b’ blue '1' tri_down marker
‘g’ green '2' tri_up marker
'3' tri_left marker
‘r’ red '4' tri_right marker
‘c’ cyan 's' square marker
'p' pentagon marker
‘m’ magenta '*' star marker
‘y’ yellow 'h' hexagon1 marker
'H' hexagon2 marker
‘k’ black
'+' plus marker
‘w’ white 'x' x marker
'D' diamond marker
'd' thin_diamond marker
'|' vline marker
'_' hline marker
Iterative plotting… it’s really this simple
Success!

You might also like