hdng / clonevol

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

Errors while plotting the tree #18

Closed jungminchoilab closed 6 years ago

jungminchoilab commented 6 years ago

Hi Ha,

Archive.zip Thanks for distributing the software. I appreciate your generosity. I generated the input for the Clonevol using pyclone (attached here) and ran the scripts following your instructions until step 4 as shown below without outputting the errors (RData files is also attached).

y = infer.clonal.models(variants = x, cluster.col.name = 'cluster', vaf.col.names = vaf.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) Sample 1: YLR107.P <-- YLR107.P Sample 2: YLR107.IR1 <-- YLR107.IR1 Sample 3: YLR107.IR <-- YLR107.IR Sample 4: YLR107.P1 <-- YLR107.P1 Sample 5: YLR107.IR2 <-- YLR107.IR2 Using monoclonal model Note: all VAFs were divided by 100 to convert from percentage to proportion. Generating non-parametric boostrap samples... YLR107.P : Enumerating clonal architectures... Determining if cluster VAF is significantly positive... Exluding clusters whose VAF < min.cluster.vaf=0.01 Non-positive VAF clusters: 5,0 YLR107.P : 6 clonal architecture model(s) found YLR107.IR1 : Enumerating clonal architectures... Determining if cluster VAF is significantly positive... Exluding clusters whose VAF < min.cluster.vaf=0.01 Non-positive VAF clusters: 2,0,5,4 YLR107.IR1 : 1 clonal architecture model(s) found YLR107.IR : Enumerating clonal architectures... Determining if cluster VAF is significantly positive... Exluding clusters whose VAF < min.cluster.vaf=0.01 Non-positive VAF clusters: 4,0,3 YLR107.IR : 1 clonal architecture model(s) found YLR107.P1 : Enumerating clonal architectures... Determining if cluster VAF is significantly positive... Exluding clusters whose VAF < min.cluster.vaf=0.01 Non-positive VAF clusters: 4,5,3 YLR107.P1 : 1 clonal architecture model(s) found YLR107.IR2 : Enumerating clonal architectures... Determining if cluster VAF is significantly positive... Exluding clusters whose VAF < min.cluster.vaf=0.01 Non-positive VAF clusters: 2,0,4,5 YLR107.IR2 : 1 clonal architecture model(s) found Finding consensus models across samples... Found 1 consensus model(s) Generating consensus clonal evolution trees across samples... Found 1 consensus model(s) Pruning consensus clonal evolution trees.... Seeding aware pruning is: off Number of unique pruned consensus trees: 1 Scoring models...

Now when I tried to plot the trees, i am getting the errors that other users have been reporting which I could not fix even after following the suggestions from you.

plot.clonal.models(y, 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', 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, 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, 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, cell.plot = TRUE, num.cells = 100, cell.border.size = 0.25, cell.border.color = 'black', clone.grouping = 'horizontal', scale.monoclonal.cell.frac = TRUE, show.score = FALSE, cell.frac.ci = TRUE, disable.cell.frac = FALSE, out.dir = 'output', out.format = 'pdf', overwrite.output = TRUE, width = 8, height = 4, panel.widths = c(3,4,2,4,2)) Error in x0[i] <- x1[which(x$branches == parent)] : replacement has length zero pdf('trees.pdf', width = 3, height = 5, useDingbats = FALSE) 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 dev.off()

I would appreciate it if you can spend time looking into my data and suggest how to fix it. Please let me know if you need additional information.

Best, Jungmin Choi

hdng commented 6 years ago

A couple of things went wrong:

The following code should work with your current data.

library(clonevol)

# read clustering, prepare data for clonevol
x = read.table('YLR107_clonevol_clean.input', header=T, stringsAsFactors=F, sep='\t')
vaf.col.names = grep('.vaf', colnames(x), value=T)
colnames(x) = gsub('.vaf', '', colnames(x))
vaf.col.names = gsub('.vaf', '', vaf.col.names)

# make sure cluster are continuous integer starting at 1
x$cluster[x$cluster == 0] = max(x$cluster) + 1

# let clonevol decide colors
clone.colors = NULL

# plot cluster of variants to make sure clustering is good
pdf('box.pdf', width = 5, height = 5, useDingbats = FALSE, title='')
pp <- plot.variant.clusters(x,
    cluster.col.name = 'cluster',
    show.cluster.size = FALSE,
    cluster.size.text.color = 'blue',
    vaf.col.names = vaf.col.names,
    vaf.limits = 70,
    sample.title.size = 20,
    violin = FALSE,
    box = FALSE,
    jitter = TRUE,
    jitter.shape = 1,
    jitter.color = clone.colors,
    jitter.size = 1,
    jitter.alpha = 1,
    jitter.center.method = 'median',
    jitter.center.size = 1,
    jitter.center.color = 'darkgray',
    jitter.center.display.value = 'none',
    highlight = 'is.driver',
    highlight.shape = 21,
    highlight.color = 'blue',
    highlight.fill.color = 'green',
    highlight.note.col.name = 'gene',
    highlight.note.size = 2,
    order.by.total.vaf = FALSE)
dev.off()

# infer tree
y = infer.clonal.models(variants = x,
    cluster.col.name = 'cluster',
    vaf.col.names = vaf.col.names,
    sample.groups = NULL,
    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 = NULL,
    min.cluster.vaf = 0.01,
    sum.p = 0.05,
    alpha = 0.05)

# always need to run this to prepare tree for plotting
y = convert.consensus.tree.clone.to.branch(y)

# now plot
plot.clonal.models(y,
    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',
    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,
    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,
    merged.tree.clone.as.branch = TRUE,
    mtcab.event.sep.char = ',',
    mtcab.branch.text.size = 1,
    mtcab.branch.width = 5,
    mtcab.node.size = 3,
    mtcab.node.label.size = 1,
    mtcab.node.text.size = 1.5,
    cell.plot = TRUE, num.cells = 100,
    cell.border.size = 0.25,
    cell.border.color = 'black',
    clone.grouping = 'horizontal',
    scale.monoclonal.cell.frac = TRUE,
    show.score = FALSE,
    cell.frac.ci = TRUE,
    disable.cell.frac = FALSE,
    out.dir = 'output', out.format = 'pdf',
    overwrite.output = TRUE,
    width = 11, height = 7,
    panel.widths = c(3,4,2,4,4))

The results should look like this.

model-1

hdng commented 6 years ago

Btw, don't forget to install the latest version of clonevol. I've just pushed lots of updates.

jungminchoilab commented 6 years ago

This is great!

Thank you so much for your prompt help.