From 7ebfedcb26edb511a42af70b3f80fe3f1900d556 Mon Sep 17 00:00:00 2001 From: Heather Grant <29428317+heathergrant@users.noreply.github.com> Date: Wed, 3 Jan 2024 17:18:01 +0000 Subject: [PATCH] luca height neoplastic progression Previous version was plotting LUCA height as the age (LUCA at age 0), even for neoplastic rules. This should now plot a floating LUCA. I think this should work for both luca rules (healthy and neoplastic). --- pisca-box-vue/app/scripts/pisca-plot.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pisca-box-vue/app/scripts/pisca-plot.R b/pisca-box-vue/app/scripts/pisca-plot.R index f70deb4..21c6a14 100644 --- a/pisca-box-vue/app/scripts/pisca-plot.R +++ b/pisca-box-vue/app/scripts/pisca-plot.R @@ -60,7 +60,6 @@ print(paste("Luca hdi=",hpdLucaHeight)) #Parsing cenancestor information from the log file #logData=fread(logDataFile) #lucaBranch=mean(logData[,luca_branch][floor(nrow(logData)*burnin):nrow(logData)]) -lucaBranch=age #lucaheight = 0 #hpdLucaHeight = 0 @@ -83,8 +82,6 @@ if (useRate == "Y"){ mccTree=read.beast(mccTreeFile) mccTreeDataFrame=fortify(mccTree) -##Tree-dependent time calculation -yearsToAdd=age-max(mccTreeDataFrame[,"x"]) #Adding luca with proper time root=which(mccTreeDataFrame$parent==mccTreeDataFrame$node) @@ -92,14 +89,17 @@ luca=nrow(mccTreeDataFrame)+1 mccTreeDataFrame[luca,]=mccTreeDataFrame[root,] mccTreeDataFrame[root,]=mccTreeDataFrame[luca,] mccTreeDataFrame[root,"parent"]=luca -mccTreeDataFrame[root,"branch.length"]=yearsToAdd -mccTreeDataFrame[luca,"x"]=max(mccTreeDataFrame[,"x"])-age +mccTreeDataFrame[root,"branch.length"]=lucaBranch +mccTreeDataFrame[luca,"x"]=-lucaBranch mccTreeDataFrame[luca,"node"]=luca +##Years to add - make x axis the age of sampling (tree file goes from 0-max height, not age) +yearsToAdd=age-max(mccTreeDataFrame[,"x"]) + #Modifying times from time from the present to time from birth mccTreeDataFrame$x=mccTreeDataFrame$x+yearsToAdd mccTreeDataFrame$branch=mccTreeDataFrame$branch+yearsToAdd -mostRecentYearsOfAge=max(mccTreeDataFrame$x) +mostRecentYearsOfAge=age mccTreeDataFrame$height_0.95_HPD=lapply(mccTreeDataFrame$height_0.95_HPD,function(x){return(c(mostRecentYearsOfAge-x[2],mostRecentYearsOfAge-x[1]))}) mccTreeDataFrame$height_0.95_HPD[luca]=list(as.numeric(c(mostRecentYearsOfAge-hpdLucaHeight[2],mostRecentYearsOfAge-hpdLucaHeight[1])))