Skip to content

Tutorial from Amidlige and MBuynak#4

Open
amidlige wants to merge 5 commits into
lyy005:masterfrom
amidlige:master
Open

Tutorial from Amidlige and MBuynak#4
amidlige wants to merge 5 commits into
lyy005:masterfrom
amidlige:master

Conversation

@amidlige

@amidlige amidlige commented Nov 3, 2017

Copy link
Copy Markdown

No description provided.

Comment thread tutorial9question2.py
return nll

initialGuess=numpy.array([1,1,1])
fit-minimize(Monod,initialGuess,method="Monod Equation",options={'disp':True},args=data)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fit=minimize(Monod,initialGuess,method="Nelder-Mead",options={'disp':True},args=data)

Comment thread tutorial9question2.py
K=p[1]
sigma=p[2]

expected=uMax* (x/(x+K))

@lyy005 lyy005 Nov 10, 2017

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected=uMax* (obs.S/(obs.S+K))

Comment thread tutorial9question2.py
sigma=p[2]

expected=uMax* (x/(x+K))
nll=-1+norm(expected,sigma).logpdf(obs.y).sum

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nll=-1+norm(expected,sigma).logpdf(obs.u).sum

Comment thread Tutorial 9 Question 3
os.chdir("/Users/madelinebuynak/Desktop")

#load data
data=pandas.read_csv("leafDecomp.csv",header=0,sep='\t')

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data=pandas.read_csv("leafDecomp.csv")

Comment thread Tutorial 9
initialGuess=numpy.array([1,1,1])
fitNull=minimize(nllike,initialGuess,method="Nelder-Mead",options={'disp':True},args=subset)
fitAlter=minimize(nllike,initialGuess,method="Nelder-Mead",options={'disp':True},args=subset)

@lyy005 lyy005 Nov 10, 2017

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subset=ponzr.loc[data.mutation.isin(['WT','M124K']),:]
input=pandas.DataFrame({'y':subset.ponzr1Counts,'design':0})
input.loc[subset.mutation=='M124K','design']=1

M124Knull=minimize(null, initialGuess,method="Nelder-Mead",args=subset)
M124Ktrt=minimize(alter, initialGuess,method="Nelder-Mead",args=subset)

1-chi2.cdf(x=2*(M124Knull.fun-M124Ktrt.fun),df=1)

Same for the other two mutations

Comment thread Tutorial 9

#I213N: p-value ~ 0.88 (no effect of treatment)


Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The structure looks good. Try to make the syntax work better
-0.5 pts

Comment thread Tutorial 9 Question 3
def alter (p,obs):
B0=p[0]
B1=p[1]
sigma=p[3]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

B2=p[2]

Comment thread Tutorial 9 Question 3
nll=-1*norm(expected,sigma).logpdf(obs.y).sum()
return nll

def alter (p,obs):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want to name the function different than the previous one

Comment thread Tutorial 9 Question 3
initialGuess=numpy.array([1,1,1])
fitNull=minimize(nllike,initialGuess,method="Nelder-Mead",options={'disp':True},args=subset)
fitAlter=minimize(nllike,initialGuess,method="Nelder-Mead",options={'disp':True},args=subset)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initialGuess=numpy.array([1,1,1,1])
fit3a=minimize(null,initialGuess,method="Nelder-Mead",options={'disp':True},args=data)
fit3b=minimize(alter1,initialGuess,method="Nelder-Mead",options={'disp':True},args=data)
fit3c=minimize(alter2,initialGuess,method="Nelder-Mead",options={'disp':True},args=data)

Comment thread Tutorial 9 Question 3


#quadratic model is the best fit, but linear model is better than constant model

@lyy005 lyy005 Nov 10, 2017

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The structure is correct. Try to improve the syntax

-0.5 pts

Comment thread tutorial9question2.py

print(fit.x)


Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-0.5 pts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants