-
Notifications
You must be signed in to change notification settings - Fork 10
Doherty Chambers Submission #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pdoherty31
wants to merge
6
commits into
lyy005:master
Choose a base branch
from
pdoherty31:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e6031e0
JC added opening the file, calculating seqLength, calculating GC perc…
jchambe5 430cf4e
JC added histogram2, changed colors and optimized bin size
jchambe5 35a4c22
question 1 complete. no question 2. working on question 3 part 1 with…
jchambe5 db9483d
finished question 3. JC
jchambe5 f3ad056
Scatter plot with trend line
pdoherty31 a8965af
Question 2
pdoherty31 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| tsg101 | ||
| actin | ||
| mhc1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # Exercise 7 | ||
|
|
||
|
|
||
| #Question 1 | ||
|
|
||
| # open fasta file | ||
| InFile=open("Lecture11.fasta","r") | ||
|
|
||
| #create lists for storing information about sequences | ||
| sequenceID=[] | ||
| sequenceLength=[] | ||
| percentGC=[] | ||
|
|
||
| #loop through each line of fasta file to process sequences | ||
| for Line in InFile: | ||
| # remove newline character from file line | ||
| Line=Line.strip() | ||
| # if a sequence record | ||
| if '>' in Line: | ||
| # add the sequence ID (except the ">" character) to the sequenceID list | ||
| sequenceID.append(Line[1:]) | ||
| # if a sequence line | ||
| else: | ||
| # get the number of characters in the sequence and convert to a float to avoid integer division | ||
| seqLen=float(len(Line)) | ||
| # count the number of G's and C's | ||
| nG=Line.count("G") | ||
| nC=Line.count("C") | ||
|
|
||
| # append values to the lists | ||
| sequenceLength.append(seqLen) | ||
| percentGC.append((nG+nC)/seqLen*100) | ||
|
|
||
| import pandas | ||
| # combine lists into dataframe | ||
| seqDF = pandas.DataFrame(list(zip(sequenceID,sequenceLength,percentGC)),columns=['sequenceID','sequenceLength','percentGC']) | ||
|
|
||
| from plotnine import * | ||
| # histogram of sequence length | ||
| histogram1=ggplot(seqDF,aes(x="sequenceLength")) | ||
| histogram1+geom_histogram(binwidth=20,fill='blue',color='black')+theme_classic() | ||
|
|
||
| # histogram of percentGC | ||
| histogram2=ggplot(seqDF,aes(x="percentGC")) | ||
| histogram2+geom_histogram()+theme_classic() | ||
| # changing colors and bins | ||
| histogram2+geom_histogram(binwidth=15,fill='yellow',color='black')+theme_classic() | ||
|
|
||
| #Question 2 | ||
| import pandas as pd | ||
| import numpy as np | ||
| data=pd.read_csv("dataset.csv") | ||
| import matplotlib.pyplot as plt | ||
| plt.title('Percent of Planted Corn in USA that is GMO') | ||
| plt.ylabel('Percent') | ||
| plt.xlabel('Year') | ||
| plt.xlim([2000,2018]) | ||
| plt.scatter(data.Year, data.Percent) | ||
| x=data.Year | ||
| y=data.Percent | ||
| z = np.polyfit(x,y, 1) | ||
| p = np.poly1d(z) | ||
| plt.plot(x,p(x),"r--") | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good job |
||
|
|
||
| #Question 3 | ||
|
|
||
| #open file and import pandas | ||
| import pandas | ||
| q3=pandas.read_csv("data.txt", sep=",", header=0) | ||
|
|
||
| #group by the region and find the mean of each region | ||
| average=q3.groupby('region')['observations'].mean() | ||
| #print to dataframe | ||
| df=average.to_frame() | ||
| #add the region rows - can find the order if you print the previous variable | ||
| df['region']=["east", "north", "south", "west"] | ||
|
|
||
| #making a bar graph with the avg of the corresponding regions | ||
| from plotnine import * | ||
| q3bp=ggplot(df)+theme_classic()+xlab("region")+ylab("observations") | ||
| q3bp+geom_bar(aes(x="region",y="observations"),stat="summary",) | ||
|
|
||
| #scatter plot with jitter applied | ||
| from plotnine import * | ||
| q3sp=ggplot(q3,aes(x="region",y="observations")) | ||
| q3sp+geom_jitter()+coord_cartesian() | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good job |
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| Year,Percent | ||
| 2000,25 | ||
| 2001,26 | ||
| 2002,34 | ||
| 2003,40 | ||
| 2004,47 | ||
| 2005,52 | ||
| 2006,61 | ||
| 2007,73 | ||
| 2008,80 | ||
| 2009,85 | ||
| 2010,86 | ||
| 2011,88 | ||
| 2012,88 | ||
| 2013,90 | ||
| 2014,93 | ||
| 2015,92 | ||
| 2016,92 | ||
| 2017,92 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job