hdng / clonevol

Inferring and visualizing clonal evolution in multi-sample cancer sequencing
GNU General Public License v3.0
141 stars 45 forks source link

tree plotting error #7

Open xtmgah opened 7 years ago

xtmgah commented 7 years ago

Hello:

I try to used the clonevol in my data (13 samples and 8 clone clusters). the infer.clonal.models run successfully without any warning or error.. But the plot.clonal.models and plot.all.trees.clone.as.branch have some error as the same following as the following:

plot.all.trees.clone.as.branch(y, branch.width = 0.5, node.size = 1, node.label.size = 0.5) Error in x0[i] <- x1[which(x$branches == parent)] : replacement has length zero

I try to get the branches information from 6 model results:

(y$matched$merged.trees[[1]])$branches [1] "100" "1" "10" "Y" "2" "3" "4"
(y$matched$merged.trees[[2]])$branches [1] "101" "1" "10" "Y" "2" "3" "102" (y$matched$merged.trees[[3]])$branches [1] "101" "1" "10" "Y" "2" "102" "3"
(y$matched$merged.trees[[4]])$branches [1] "101" "1" "10" "Y" "102" "2" "3"
(y$matched$merged.trees[[5]])$branches [1] "101" "1" "10" "Y" "102" "2" "103" (y$matched$merged.trees[[6]])$branches [1] "101" "1" "10" "Y" "102" "103" "2"

Can you let me know why the tree plot failed? Thanks.

hdng commented 7 years ago

Could you attach all commands that you ran on this case?

xtmgah commented 7 years ago

Here is my commands. And the tmp.RData have been attached. Thanks. tmp.RData.zip

load("tmp.RData") y = infer.clonal.models(variants = data, cluster.col.name = 'cluster', vaf.col.names = vaf.col.names,

sample.groups = sample.groups,

                    subclonal.test = 'bootstrap',
                    subclonal.test.model = 'non-parametric',
                    num.boots = 1000,
                    founding.cluster = founding.cluster,
                    cluster.center = 'mean',
                    ignore.clusters = NULL,
                    clone.colors = clone.colors,
                    min.cluster.vaf = min.cluster.vaf,
                    sum.p.cutoff = 0.01,
                    alpha = 0.05)

y <- convert.consensus.tree.clone.to.branch(y, branch.scale = 'sqrt')

plot.all.trees.clone.as.branch(y, branch.width = 0.5, node.size = 1, node.label.size = 0.5)

plot.clonal.models(y,

box plot parameters

               box.plot = TRUE,
               fancy.boxplot = TRUE,
               fancy.variant.boxplot.highlight = 'is.driver',
               fancy.variant.boxplot.highlight.shape = 21,
               fancy.variant.boxplot.highlight.fill.color = 'red',
               fancy.variant.boxplot.highlight.color = 'black',
               fancy.variant.boxplot.highlight.note.col.name = 'gene',
               fancy.variant.boxplot.highlight.note.color = 'blue',
               fancy.variant.boxplot.highlight.note.size = 2,
               fancy.variant.boxplot.jitter.alpha = 1,
               fancy.variant.boxplot.jitter.center.color = 'grey50',
               fancy.variant.boxplot.base_size = 12,
               fancy.variant.boxplot.plot.margin = 1,
               fancy.variant.boxplot.vaf.suffix = '.VAF',
               # bell plot parameters
               clone.shape = 'bell',
               bell.event = TRUE,
               bell.event.label.color = 'blue',
               bell.event.label.angle = 60,
               clone.time.step.scale = 1,
               bell.curve.step = 2,
               # node-based consensus tree parameters
               merged.tree.plot = TRUE,
               tree.node.label.split.character = NULL,
               tree.node.shape = 'circle',
               tree.node.size = 30,
               tree.node.text.size = 0.5,
               merged.tree.node.size.scale = 1.25,
               merged.tree.node.text.size.scale = 2.5,
               merged.tree.cell.frac.ci = FALSE,
               # branch-based consensus tree parameters
               merged.tree.clone.as.branch = TRUE,
               mtcab.event.sep.char = ',',
               mtcab.branch.text.size = 1,
               mtcab.branch.width = 0.75,
               mtcab.node.size = 3,
               mtcab.node.label.size = 1,
               mtcab.node.text.size = 1.5,
               # cellular population parameters
               cell.plot = TRUE,
               num.cells = 100,
               cell.border.size = 0.25,
               cell.border.color = 'black',
               clone.grouping = 'horizontal',
               #meta-parameters
               scale.monoclonal.cell.frac = TRUE,
               show.score = FALSE,
               cell.frac.ci = TRUE,
               disable.cell.frac = FALSE,
               # output figure parameters
               out.dir = 'output',
               out.format = 'pdf',
               overwrite.output = TRUE,
               width = 28,
               height = 14,
               # vector of width scales for each panel from left to right
               panel.widths = c(3,4,1,3,1),
               max.num.models.to.plot=3

)

hdng commented 7 years ago

Seems like a bug with cluster ordering. To overcome this, I added these after load('tmp.RData'):

clusters = 1:7 names(clusters) = as.character(c(5, 4, 2, 8, 6, 9, 10)) data$cluster = clusters[as.character(data$cluster)] founding.cluster = 1

zypiner commented 6 years ago

Hello,

I have the same issue. I used clonevol on two samples and four clones. When I used the function 'plot.clonal.models' to draw trees, I have error " Error in x0[i] <- x1[which(x$branches == parent)] : replacement has length zero Warning messages: convert.consensus.tree.clone.to.branch(y) 1: Removed 1 rows containing non-finite values (stat_summary). plot.all.trees.clone.as.branch(y, branch.width = 0.5,node.size = 1, node.label.size = 0.5) 2: Removed 1 rows containing missing values (geom_point). "

I tried to change mpal_wdfmt_p_r$cluster to character or integer, but the error still exist.

I am really appreciated if you could help me to solve this problem. Thank you very much.

Here is my data: clonevol_inputdt.RData.zip

The command I executed is:

library(data.table) library(clonevol)

load('clonevol_inputdt.RData') vaf.col.names <- grep('vaf', colnames(mpal_wdfmt_p_r), value=T) sample.groups <- c('lm130227', 'lm160218') names(sample.groups) <- vaf.col.names ccf.col.names<- grep('ccf', colnames(mpal_wdfmt_p_r), value=T) clone.colors <- NULL

y = infer.clonal.models(variants = mpal_wdfmt_p_r, cluster.col.name = 'cluster', vaf.col.names = vaf.col.names,

ccf.col.names = ccf.col.names,

sample.groups = sample.groups, cancer.initiation.model='monoclonal', subclonal.test = 'bootstrap', subclonal.test.model = 'non-parametric', num.boots = 1000, founding.cluster = 3, cluster.center = 'mean', ignore.clusters = NULL, clone.colors = clone.colors, min.cluster.vaf = 0.01, sum.p = 0.05, alpha = 0.05)

y = convert.consensus.tree.clone.to.branch(y)

plot.all.trees.clone.as.branch(y, branch.width = 0.5,node.size = 1, node.label.size = 0.5)

plot.clonal.models(y,

box plot parameters

               box.plot = TRUE,
               fancy.boxplot = TRUE,
               fancy.variant.boxplot.highlight = 'is.driver',
               fancy.variant.boxplot.highlight.shape = 21,
               fancy.variant.boxplot.highlight.fill.color = 'red',
               fancy.variant.boxplot.highlight.color = 'black',
               fancy.variant.boxplot.highlight.note.col.name = 'gene',
               fancy.variant.boxplot.highlight.note.color = 'blue',
               fancy.variant.boxplot.highlight.note.size = 2,
               fancy.variant.boxplot.jitter.alpha = 1,
               fancy.variant.boxplot.jitter.center.color = 'grey50',
               fancy.variant.boxplot.base_size = 12,
               fancy.variant.boxplot.plot.margin = 1,
               fancy.variant.boxplot.vaf.suffix = '.VAF',
               # bell plot parameters
               clone.shape = 'bell',
               bell.event = TRUE,
               bell.event.label.color = 'blue',
               bell.event.label.angle = 60,
               clone.time.step.scale = 1,
               bell.curve.step = 2,
               # node-based consensus tree parameters
               merged.tree.plot = TRUE,
               tree.node.label.split.character = NULL,
               tree.node.shape = 'circle',
               tree.node.size = 30,
               tree.node.text.size = 0.5,
               merged.tree.node.size.scale = 1.25,
               merged.tree.node.text.size.scale = 2.5,
               merged.tree.cell.frac.ci = FALSE,
               # branch-based consensus tree parameters
               merged.tree.clone.as.branch = TRUE,
               mtcab.event.sep.char = ',',
               mtcab.branch.text.size = 1,
               mtcab.branch.width = 0.75,
               mtcab.node.size = 3,
               mtcab.node.label.size = 1,
               mtcab.node.text.size = 1.5,
               # cellular population parameters
               cell.plot = TRUE,
               num.cells = 100,
               cell.border.size = 0.25,
               cell.border.color = 'black',
               clone.grouping = 'horizontal',
               #meta-parameters
               scale.monoclonal.cell.frac = TRUE,
               show.score = FALSE,
               cell.frac.ci = TRUE,
               disable.cell.frac = FALSE,
               # output figure parameters
               out.dir = 'output',
               out.format = 'pdf',
               overwrite.output = TRUE,
               width = 11,
               height = 7,
               # vector of width scales for each panel from left to right
               panel.widths = c(3,4,2,4,2))
hdng commented 6 years ago

Sorry for the late reply. This is a known bug when your cluster ID is not consecutive and founding clone is not 1. I'll release a fix soon. The workaround is to add the following code before infer.clonal.models, to make sure founding clone is 1:

c3 = mpal_wdfmt_p_r$cluster == 3
c1 = mpal_wdfmt_p_r$cluster == 1
mpal_wdfmt_p_r$cluster[c1] = 3
mpal_wdfmt_p_r$cluster[c3] = 1
mpal_wdfmt_p_r = mpal_wdfmt_p_r[order(mpal_wdfmt_p_r$cluster),]

and change the founding.cluster in infer.clonal.models to 1, as follows:

y = infer.clonal.models(variants = mpal_wdfmt_p_r,
  cluster.col.name = 'cluster',
  vaf.col.names = vaf.col.names,
  #ccf.col.names = ccf.col.names,
  sample.groups = sample.groups,
  cancer.initiation.model='monoclonal',
  subclonal.test = 'bootstrap',
  subclonal.test.model = 'non-parametric',
  num.boots = 1000,
  founding.cluster = 1,
  cluster.center = 'mean',
  ignore.clusters = NULL,
  clone.colors = clone.colors,
  min.cluster.vaf = 0.01,
  sum.p = 0.05,
  alpha = 0.05)