【问题标题】:How can I plot the genealogy of a user created population?如何绘制用户创建人口的家谱?
【发布时间】:2016-08-31 01:11:59
【问题描述】:

我编写了一个代码来模拟 Wright-Fisher 遗传漂变模型。这意味着 N 个不同个体的原始种群将有无限的后代种群,然后随机选择决定下一代。我想创建一个图表,可以在这些世代中遵循每条线,如下图所示。 Here one particular ancestor's line is highlighted. Any sort of tracking of ancestor lines would be ideal.

谢谢!我在下面提供了我的代码:

 Simulates Wright-Fisher model for N different haploid individuals

N <- 10             # Number of individuals
gens <- 40          # Number of generations model will run
init.j <- 1:1:N     # Creates vector of initial population lines
p <- 1/N            # Frequency of each individual's alleles
                # note that two indiv may share same allele but are considered different 
p.vector <- rep(p,N) # creates vector of length N with the prob 1/N in each position
p.pick <- cumsum(p.vector)


j=matrix(init.j,N,gens+1)  #Creates matrix that will track each individual's     progeny line

for(i in 1:gens+1){  
  for(k in 1:N){
y = runif(1, min=0, max=1)
x <- p.pick - y
b <- min(x[which(x > 0,arr.ind = TRUE)]) 
j[k,i] = match(b,x)
  }
}  

J = apply(j, 2, sort) #Sorts each column to align ancestors with next generation which helps for visualization of genealogy

【问题讨论】:

    标签: plot rstudio genetics


    【解决方案1】:

    看起来你想要一个多树:

    https://en.wikipedia.org/wiki/Multitree

    我唯一发现的是多树:

    http://psycho3.uni-mannheim.de/Home/Research/Software/multiTree/

    有 R 代码与此接口:

    http://www.ncbi.nlm.nih.gov/pubmed/20160285

    但是,似乎该软件包不在 CRAN 上,并且摘要中引用的网站不再存在。

    【讨论】:

      猜你喜欢
      • 2015-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多