EvolutionAfterTreatment: Display node transition with specified treatment plan or...

View source: R/EvolutionAfterTreatment.R

EvolutionAfterTreatmentR Documentation

Display node transition with specified treatment plan or exposure

Description

Calculate the number of subjects (proportion) assigned to different sub-nodes after specified treatment plan or exposure in certain node.

Usage

EvolutionAfterTreatment(
df,
treepoint,
mytree,
source,
treatment
)

Arguments

df

"data" in the return result of the survivalpath() function

treepoint

list object;Specify the node for drawing the KM curve, the node number is displayed in the survival path tree graph.

mytree

"tree" in the return result of the survivalpath() function

source

Data.frame of time slice data, which could be returned by timedivision()

treatment

Factor variable in the source data.frame. This argument is to specify the intervention or exposure that of interest at a specific node.

Value

A data.frame object, whose rows and columns represents the number of subjects in the sub-nodes (in the next time slice) and treatment plan, respectively.

Examples

library(dplyr)
data("DTSDHCC")
id = DTSDHCC$ID[!duplicated(DTSDHCC$ID)]
set.seed(123)
id = sample(id,500)
miniDTSDHCC <- DTSDHCC[DTSDHCC$ID %in% id,]
dataset = timedivision(miniDTSDHCC,"ID","Date",period = 90,left_interval = 0.5,right_interval=0.5)
resu <- generatorDTSD(dataset,periodindex="time_slice",IDindex="ID" ,timeindex="OStime_day",
 statusindex="Status_of_death",variable =c( "Age", "Amount.of.Hepatic.Lesions",
 "Largest.Diameter.of.Hepatic.Lesions",
 "New.Lesion","Vascular.Invasion" ,"Local.Lymph.Node.Metastasis",
 "Distant.Metastasis" , "Child_pugh_score" ,"AFP"),predict.time=365*1)
result <- survivalpath(resu,time_slices =9)
mytree <- result$tree

#Draw the survival Path model
library(ggplot2)
library(ggtree)
ggtree(mytree, color="black",linetype=1,size=1.2,ladderize = TRUE )+
 theme_tree2() +
 geom_text2(aes(label=label),hjust=0.6, vjust=-0.6 ,size=3.0)+
 geom_text2(aes(label=paste(node,size,mytree@data$survival,mytree@data$survivalrate,sep = "/")),
 hjust=0.6, vjust=-1.85 ,size=3.0)+
 #geom_point2(aes(shape=isTip, color=isTip), size=mytree1@data$os/40)+
 geom_point2(aes(shape=isTip, color=isTip), size=mytree@data$size%/%200+1,show.legend=FALSE)+
 #guides(color=guide_legend(title="node name/sample number/Median survival time/Survival rate")) +
 labs(size= "Nitrogen",
      x = "TimePoints",
      y = "Survival",
      subtitle = "node_name/sample number/Median survival time/Survival rate",
      title = "Survival Tree") +
 theme(legend.title=element_blank(),legend.position = c(0.1,0.9))

treepoint=15
A = EvolutionAfterTreatment(result$data, treepoint,mytree,dataset,"Resection")
mytable <- xtabs(~ `Resection`+treepoint, data=A)
prop.table(mytable,1)


SurvivalPath documentation built on July 4, 2022, 1:05 a.m.