Skip to content

Instantly share code, notes, and snippets.

@chrisamiller
Last active March 18, 2024 12:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrisamiller/f4eae5618ec2985e105d05e3032ae674 to your computer and use it in GitHub Desktop.
Save chrisamiller/f4eae5618ec2985e105d05e3032ae674 to your computer and use it in GitHub Desktop.
Fishplot - Updated Clonevol Integration in Additional File 2
library(sciClone)
library(clonevol)
library(fishplot)
## read in the data - copy number
cn1 = read.table("tumor.cn",sep="\t",stringsAsFactors=F)
cn2 = read.table("relapse.cn",sep="\t",stringsAsFactors=F)
cn1 = cn1[,c(1,2,3,5)]
cn2 = cn2[,c(1,2,3,5)]
## read in vaf data
v1=read.table("tumor.vafs",sep="\t",stringsAsFactors=F,header=T)
v2=read.table("relapse.vafs",sep="\t",stringsAsFactors=F,header=T)
samples = c("Tumor","Relapse")
## run sciclone to detect clusters
sc = sciClone(vafs=list(v1,v2),
copyNumberCalls=list(cn1,cn2),
sampleNames=samples,
useSexChrs=FALSE, doClusteringAlongMargins=FALSE)
writeClusterTable(sc, "clusters")
sc.plot2d(sc,"clusters.2d.pdf")
## prepare clonevol input
vafs = data.frame(cluster=sc@vafs.merged$cluster,
tvaf=sc@vafs.merged$Tumor.vaf,
rvaf=sc@vafs.merged$Relapse.vaf,stringsAsFactors=F)
vafs = vafs[!is.na(vafs$cluster) & vafs$cluster > 0,]
names(vafs)[2:3] = samples
## run clonevol
res = infer.clonal.models(variants=vafs, cluster.col.name="cluster", vaf.col.names=samples,
subclonal.test="bootstrap", subclonal.test.model="non-parametric",
cluster.center="mean", num.boots=1000, founding.cluster=1,
min.cluster.vaf=0.01, sum.p=0.01, alpha=0.1, random.seed=63108)
# new clonevol
res = convert.consensus.tree.clone.to.branch(res, branch.scale='sqrt')
# new clonevol
plot.clonal.models(res, box.plot=TRUE, fancy.boxplot=TRUE, cell.plot=TRUE,
out.format="pdf", overwrite.output=TRUE, scale.monoclonal.cell.frac=TRUE,
cell.frac.ci=TRUE, tree.node.shape="circle", tree.node.size=40,
tree.node.text.size=0.65, width=8, height=5, out.dir=".")
## create a list of fish objects - one for each model (in this case, there's only one)
f = generateFishplotInputs(results=res)
fishes = createFishPlotObjects(f)
## plot each of these with fishplot
pdf('fish.pdf', width=8, height=4)
for (i in 1:length(fishes)){
fish = layoutClones(fishes[[i]])
fish = setCol(fish,f$clonevol.clone.colors)
fishPlot(fish,shape="spline", title.btm="PatientID", cex.title=0.7,
vlines=seq(1, length(samples)), vlab=samples, pad.left=0.5)
}
dev <- dev.off()
@YT-er
Copy link

YT-er commented Jul 14, 2017

when I run this script with the tumor and relapse data, has a error:

plot.clonal.models(res$models, matched=res$matched, variants=vafs, box.plot=TRUE,

  •                out.format="pdf", overwrite.output=TRUE, scale.monoclonal.cell.frac=TRUE,
    
  •                cell.frac.ci=TRUE, tree.node.shape="circle", tree.node.size=40,
    
  •                tree.node.text.size=0.65, width=8, height=5, out.dir=".")
    

Error in data.frame(x = c(xstarts, xstops), index = seq(1, 2 * k)) :
arguments imply differing number of rows: 0, 2
In addition: Warning message:
In min(xstarts) : no non-missing arguments to min; returning Inf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment