mercredi 24 mai 2017

Simulations in R using probability

myfunction3 <- function(seq2,z)


for(j in 1:100)

{

if(z[j]>0.7)

{  
if(seq2[j] =='A')  replace(seq2,j,sample(c("C","G","T"),1))

else if(seq2[j] =='G')  replace(seq2,j,sample(c("C","A","T"),1))

else if(seq2[j] =='T')  replace(seq2,j,sample(c("C","G","A"),1))

else if(seq2[j] =='C')  replace(seq2,j,sample(c("A","G","T"),1))

else if(seq2[j]=='E')   replace(seq2,j,'T')

}

}

return(seq2)

I have written this function to simulate a given DNA sequence seq2 according to the probability vector z in which if the probability is greater than 0.7 then the new sequence can have any of the other three nucleotides(A,G,T,C) in its place. But everytime it is returning a NULL vector.




Aucun commentaire:

Enregistrer un commentaire