首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
CS 369代做、代写Python编程语言
项目预算:
开发周期:
发布时间:
要求地区:
CS 369 2024 Assignment 4
See Canvas for due dates
In the ffrst part of this assignment, we use a Hidden Markov Model to model secondary
structure in protein sequences and implement a couple of algorithms we saw in lectures.
In the second part, we simulate sequences down a tree according to the Jukes-Cantor
model then use distance methods to try to reconstruct the tree.
Write your code in Python and present your code embedded in a report in a Jupyter
Notebook. Make sure you test your code thoroughly and write clear, commented code
that others can understand.
Submit two ffles to Canvas: the .ipynb and .html both showing code and results by 10pm
on the due date.
There are 30 marks in total for this assessment.
1. [14 marks total] Suppose we wish to estimate basic secondary structure in protein
(amino acid) sequences. The model we consider is a simplistic rendition of the
model discussed in S C. Schmidler et al. (2004) Bayesian Segmentation of Protein
Secondary Structure, doi:10.1089/10665270050081496
We assume that at each point of the sequence, the residue is associated with one
of three secondary structures: α-helix, β-strand and loops which we label H, S
and T, respectively. To simplify the problem, we classify the amino acids as either
hydrophobic, hydrophilic or neutral (B, I or N, respectively) so a sequence can be
represented by this 3-letter alphabet.
In a α-helix, the residues are 15% neutral, 20% hydrophobic and 65% hydrophilic.
In a β-strand, they are 30%, 60%, 10% and in a loop they are 70%, 15%, 15%.
Assume that all secondary structures have geometrically distributed length with
α-helices having mean 15 residues, β-strands having a mean of 8 residues and loops
a mean of 6 residues. A β-strand is followed by an α-helix 40% of the time and a
loop 60% of the time. An α-helix is followed by a β-strand 30% of the time and a
loop 70% of the time and a loop is equally likely to be followed by a strand or a
helix. At the start of a sequence, any structure is equally likely.
When writing code below, work in natural logarithms throughout to make your
calculations robust to numerical error.
(a) [3 marks] Sketch a diagram of the HMM (a hand-drawn and scanned picture
is ffne). In your diagram, show only state nodes and transitions. Show the
emission probabilities using a separate table.
Note that the transition probabilities of states to themselves (e.g., aHH) are
not given. Derive them by noticing that you are given the expected lengths
of α-helices, β-strands and loops, and that if a quantity L is geometrically
distributed with parameter p then the expected value of L is E[L] = 1/p.
Make sure you use the correct parametrisation of the geometric distribution
1(noting that you can’t have a secondary structure of length 0) and remember
that
P
l
akl = 1 for any state k.
(b) [3 marks] Write a method to simulate state and symbol sequences of arbitrary
length from the HMM. Your method should take sequence length, and model
parameters (a and e) as arguments. Simulate and print out a state and symbol
sequence of length 200.
(c) [3 mark] Write a method to calculate the natural logarithm of the joint probability
P(x, π). Your method should take x, π, and model parameters as
arguments.
Use your method to calculate P(x, π) for π and x given below and for the
sequences you simulated in Q1b.
π = S,S,H,H,H,T,T,S,S,S,H,T,T,H,H,H,S,S,S,S,S,S
x = B,I,B,B,N,I,N,B,N,I,N,B,I,N,B,I,I,N,B,B,N,N
(d) [5 marks] Implement the forward algorithm for HMMs to calculate the natural
logarithm of the probability P(x). Your method should take x as an argument.
Note that we don’t model the end state here.
Use your method to calculate log(P(x)) for π and x given in Q1c and for the
sequences you simulated in Q1b.
How does P(x) compare to P(x, π) for the examples you calculated? Does
this relationship hold in general? Explain your answer.
22. [16 marks total] In this question you will write a method that simulates random
trees, simulates sequences using a mutation process on these trees, calculate a
distance matrix from the simulated sequences and then, using existing code, reconstruct
the tree from this distance matrix.
(a) [5 marks] Write a method that simulates trees according to the Yule model
(described below) with takes as input the number of leaves, n, and the branching
parameter, λ. Use the provided Python classes.
The Yule model is a branching process that suggests a method of constructing
trees with n leaves. From each leaf, start a lineage going back in time. Each
lineage coalesces with others at rate λ. When there k lineages, the total rate
of coalescence in the tree is kλ. Thus, we can generate a Yule tree with n
leaves as follows:
Set k = n,t = 0.
Make n leaf nodes with time t and labeled from 1 to n. This is the set of
available nodes.
While k > 1, iterate:
Generate a time tk ∼ Exp (kλ). Set t = t + tk.
Make a new node, m, with height t and choose two nodes, i and j,
uniformly at random from the set of available nodes. Make i and j
the child nodes of m.
Add m to the set of available nodes and remove i and j from this set.
Set k = k-1.
Simulate 1000 trees with λ = 0.5 and n = 10 and check that the mean height
of the trees (that is, the time of the root node) agrees with the theoretical
mean of 3.86.
Use the provided plot tree method to include a picture of a simulated tree
with 10 leaves and λ = 0.5 in your report. To embed the plot in your report,
include in the ffrst cell of your notebook the command %matplotlib inline
(b) [5 marks] The Jukes-Cantor model of DNA sequence evolution is simple:
each site mutates at rate µ and when a mutation occurs, a new base is chosen
uniformly at random from the four possible bases, {A, C, G, T}. If we ignore
mutations from base X to base X, the mutation rate is
3
4
µ. All sites mutate
independently of each other. A sequence that has evolved over time according
to the Jukes-Cantor model has each base equally likely to occur at each site.
The method mutate is provided to simulate the mutation process.
Write a method to simulate sequences down a simulated tree according to the
Jukes-Cantor model.
Your method should take a tree with n leaves, sequence length L, and a
mutation rate µ. It should return either a matrix of sequences corresponding
to nodes in the tree or the tree with sequences stored at the nodes.
3Your method should generate a uniform random sequence of length L at the
root node and recursively mutate it down the branches of the tree, using the
node heights to calculate branch length.
In your report, include a simulated tree with n = 10 and λ = 0.5 and a set
of sequences of length L = 20 and mutation parameter µ = 0.5 simulated on
that tree.
(c) [3 marks] Write a method to calculate the Jukes-Cantor distance matrix, d,
from a set of sequences, where dij is the distance between the ith and the
jth sequences. Recall that the Jukes-Cantor distance for sequences x and y
is deffned by
where fxy is the fraction of differing sites between x and y. Since we will be
dealing with short sequences, use the following deffnition of fxy so that the
distances are well-deffned:
fxy = min
where Dxy is the number of differing sites between x and y and L is the length
of x.
Include a simulated set of sequences of length L = 20 from the tree leaves and
corresponding distance matrix in your report for a tree with n = 10, λ = 0.5
and mutation parameter µ = 0.5.
(d) [3 marks] Now simulate a tree with n = 10 and λ = 0.5 and on that tree,
simulate three sets of sequences with lengths L = 20, L = 50 and L = 200,
respectively, with ffxed µ = 0.1. For each simulated set of sequences, calculate
the distance matrix and print it out.
Then reconstruct the tree using the provided compute upgma tree method.
Use the plot tree method to include a plot of the original tree and a plot of
the reconstructed tree for each distance matrix.
Comment on the quality of the reconstructions and the effect that increasing
the sequence length has on the accuracy of the reconstruction.
4
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做 program、代写 c++设计程...
2024-12-23
comp2012j 代写、代做 java 设...
2024-12-23
代做 data 编程、代写 python/...
2024-12-23
代做en.553.413-613 applied s...
2024-12-23
代做steady-state analvsis代做...
2024-12-23
代写photo essay of a deciduo...
2024-12-23
代写gpa analyzer调试c/c++语言
2024-12-23
代做comp 330 (fall 2024): as...
2024-12-23
代写pstat 160a fall 2024 - a...
2024-12-23
代做pstat 160a: stochastic p...
2024-12-23
代做7ssgn110 environmental d...
2024-12-23
代做compsci 4039 programming...
2024-12-23
代做lab exercise 8: dictiona...
2024-12-23
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!