CIP2A / scripts /plate_layouts.R
xuyun's picture
Add CIP2A SCLC reproducibility materials
1fa45cf verified
Raw History Blame Contribute Delete
8.2 kB
plate <- function(name, panel, height=140) {
for (fmt in c("pdf","png")) {
path <- file.path(root,paste0(name,".",fmt))
if (fmt=="pdf") pdf(path,width=183/25.4,height=height/25.4,pointsize=8,useDingbats=FALSE)
else png(path,width=183/25.4,height=height/25.4,units="in",res=300,pointsize=8,type=png_device)
par(mar=c(3.8,4.9,2.1,1.05),mgp=c(2.4,.62,0),las=1,bty="l",cex.axis=.9,tcl=-.23)
set.seed(45)
panel()
dev.off()
}
}
plate("Figure1",function(){
layout(matrix(c(1,2,3,3),2,byrow=TRUE),heights=c(1.1,1))
x <- subset(t,accession=="GSE149507")
x <- reshape(x[c("patient","tissue","CIP2A")],idvar="patient",timevar="tissue",direction="wide")
stopifnot(nrow(x)==18)
plot(NA,xlim=c(.7,2.3),ylim=range(x[-1]),xaxt="n",xlab="",ylab="Published log2 expression")
axis(1,1:2,c("Adjacent lung","SCLC"))
segments(1,x$CIP2A.normal,2,x$CIP2A.tumor,col=adjustcolor(pal[1],.45))
points(rep(1,18),x$CIP2A.normal,pch=16,col=pal[1],cex=.65)
points(rep(2,18),x$CIP2A.tumor,pch=16,col=pal[1],cex=.65)
ttl("A GSE149507")
x <- subset(t,accession=="GSE60052")
strip(list(x$CIP2A[x$tissue=="normal"],x$CIP2A[x$tissue=="tumor"]),
c("Normal lung","SCLC"),"Published log2 expression")
ttl("B GSE60052")
par(mar=c(4.0,7.1,2.2,1.05))
y <- 2:1
plot(te$mean_difference,y,xlim=c(0,6.8),ylim=c(.58,2.55),xaxt="n",yaxt="n",pch=19,col=accent,
xlab="",ylab="",bty="n")
axis(1,0:3)
axis(2,y,te$accession,las=1,tick=FALSE)
segments(0,.67,0,2.22,col="grey55",lty=2)
segments(te$ci_low,y,te$ci_high,y,lwd=1.6,col=accent)
points(te$mean_difference,y,pch=19,col=accent)
text(3.55,y,sprintf("%d / %d %+.2f [%.2f, %.2f]",te$n_tumor,te$n_normal,te$mean_difference,te$ci_low,te$ci_high),adj=0,cex=.88)
text(3.55,2.36,"Tumor / lung Difference [95% CI]",adj=0,font=2,cex=.85)
mtext("Tumor minus lung (log2 units)",side=1,line=2.2,at=1.6)
ttl("C Cohort-specific effect estimates")
},height=122)
plate("Figure2",function(){
layout(matrix(c(1,2,3,3),2,byrow=TRUE),widths=c(1.15,1),heights=c(1.8,1))
z <- r[order(r$dependency,decreasing=TRUE),]
y <- seq_len(nrow(z))
col <- ifelse(z$model_name=="NCI-H1836",accent,
ifelse(z$model_name %in% c("NCI-H211","DMS 53"),pal[2],"grey54"))
for(k in 1:2) {
par(mar=c(3.8,if(k==1) 7.0 else 1.1,2.1,1.05))
v <- z[[c("chronos","dependency")[k]]]
plot(v,y,type="n",ylim=c(.4,11.6),xlim=if(k==1) c(-.8,.06) else c(-.94,.16),
yaxt="n",ylab="",xlab=c("Chronos gene effect","DEMETER2 score")[k])
if(k==1) axis(2,y,z$model_name,las=1,tick=FALSE,cex.axis=.83)
abline(h=y,col="#ECEFF1",lwd=.55)
abline(v=0,lty=2,col="grey55")
segments(0,y,v,y,col=col)
points(v,y,pch=ifelse(col=="grey54",16,18),col=col,cex=.93)
ttl(c("A CRISPR knockout","B RNAi knockdown")[k])
}
par(mar=c(3.5,5.0,2.1,1.05))
strip(list(g$chronos[g$group=="LUAD"],g$chronos[g$group=="SCLC"]),c("LUAD (47)","SCLC (23)"),"Chronos gene effect",-.5)
ttl("C CRISPR effects across histologies")
},height=139)
plate("Figure3",function(){
u <- read("chan_umap.csv")
stopifnot(nrow(u)==11744,all(u$detected %in% c(0,1)))
layout(rbind(1:4,5:8,c(9,9,10,10)),heights=c(1,1,1.35))
ids <- unique(sort(u$patient))
cols <- c(malignant=pal[2],nonmalignant_epithelial=pal[1],immune="#5777A1",
Fibroblast="#BB8B3F",Endothelial="#765896",other="#818181")
ranges <- list(range(u$UMAP1),range(u$UMAP2))
for(kind in c("labels","detected")) for(i in seq_along(ids)){
z <- u[u$patient==ids[i],]
par(mar=c(.9,if(i==1) 2.7 else .25,if(kind=="labels") 2 else .2,.25))
plot(NA,xlim=ranges[[1]],ylim=ranges[[2]],asp=1,axes=FALSE,xlab="",ylab="")
box(col="#D8DDE1",lwd=.5)
if(kind=="labels") points(z$UMAP1,z$UMAP2,pch=16,cex=.28,col=adjustcolor(cols[z$group],.62))
else {
j <- z$detected==1
points(z$UMAP1[!j],z$UMAP2[!j],pch=16,cex=.24,col="#CAD0D5")
points(z$UMAP1[j],z$UMAP2[j],pch=16,cex=.35,col="#A03951")
}
if(kind=="labels") title(paste("Patient",sub("HTA8_","",ids[i])),cex.main=.88)
if(i==1) mtext(if(kind=="labels") "A Labels" else "B CIP2A",side=2,line=1.0,las=0,cex=.84)
}
par(mar=c(3.7,4.6,2.1,1.1))
z <- subset(p,stratum=="all")
plot(NA,xlim=c(.72,2.28),ylim=c(0,52),xaxt="n",xlab="",ylab="CIP2A CPM")
axis(1,1:2,c("Lung epithelium","Tumor group"))
for(i in seq_len(nrow(z))) {
k <- 1+(z$cohort[i]!="Chan")
lines(1:2,c(z$cpm_nonmalignant_epithelial[i],z$cpm_malignant[i]),type="o",pch=c(16,17)[k],col=pal[k],lwd=1)
}
ttl("C Paired patient-level expression")
legend("topleft",c("Chan","GSE281740"),col=pal,pch=c(16,17),lty=1,bty="n",cex=.8)
par(mar=c(.8,1.1,2.0,.5)); plot.new(); plot.window(xlim=c(0,1),ylim=c(0,1))
ttl("D Cells contributing to C")
text(c(.05,.57,.93),.94,c("Patient","Epithelium","Tumor"),adj=0,font=2,cex=.88)
yy <- seq(.78,.43,length.out=nrow(z))
text(.05,yy,toupper(sub("HTA8_","",z$sample)),adj=0,cex=.88)
text(.57,yy,z$cells_nonmalignant_epithelial,adj=0,cex=.88)
text(.93,yy,z$cells_malignant,adj=1,cex=.88)
legend(.02,.31,c("Tumor group","Lung epithelium","Immune","Fibroblast","Endothelial","Other"),
col=unname(cols),pch=16,ncol=2,bty="n",cex=.73,y.intersp=1.1)
text(.04,.03,"Panel B: burgundy = detected; gray = zero counts",adj=0,cex=.73)
},height=159)
plate("Figure4",function(){
layout(matrix(1:2,nrow=1),widths=c(1,1.13))
par(mar=c(4.25,4.35,2,1))
z <- subset(p,cohort=="GSE281740" & stratum %in% c("all","low_cycle"))
plot(NA,xlim=c(.62,2.38),ylim=c(-4,48),xaxt="n",xlab="",ylab="Tumor minus epithelial (CPM)")
axis(1,1:2,c("All cells","Low-cycle markers"))
abline(h=0,lty=2,col="grey55")
for(i in 1:2){
x <- z[z$sample==c("ru1334","ru1449a")[i],]
lines(1:2,x$delta_cpm[match(c("all","low_cycle"),x$stratum)],type="o",col=pal[i],pch=c(16,17)[i],lwd=1.2)
}
legend("topright",c("RU1334","RU1449A"),col=pal,pch=c(16,17),lty=1,bty="n",cex=.85)
ttl("A Effect after cycle stratification")
q <- subset(read("gse281740_cnv_effects.csv"),stratum=="low_cycle_depth_matched")
par(mar=c(2.4,1.05,2,1)); plot.new(); plot.window(xlim=c(0,1),ylim=c(0,1))
ttl("B Counts after low-cycle depth matching")
heads <- c("Patient","Group","Cells","Total UMI","CIP2A UMI")
xx <- c(.015,.23,.61,.80,.995)
for(i in 1:5) text(xx[i],.93,heads[i],adj=if(i<=2) 0 else 1,font=2,cex=.81)
segments(.01,.86,.99,.86,col="grey70")
q <- q[order(q$sample,q$group),]
for(i in seq_len(nrow(q))){
v <- q[i,]
labels <- c(toupper(v$sample),if(v$group=="CNV_low_epithelial") "Lung epithelium" else "Tumor group",
v$cells,format(v$umi,big.mark=","),v$cip2a)
y <- .75-(i-1)*.16
for(j in 1:5) text(xx[j],y,labels[j],adj=if(j<=2) 0 else 1,cex=.84,font=if(j==5) 2 else 1)
}
},height=79)
plate("GraphicalAbstract",function(){
layout(matrix(1:3,nrow=1),widths=c(1.2,1,1.05))
par(mar=c(2.9,.9,2.3,.85))
plot.new(); plot.window(xlim=c(0,1),ylim=c(0,1))
ttl("A Public data")
y <- c(.79,.5,.21)
rect(.05,y-.09,.95,y+.09,col=c("#E1EDEB","#F1E2E7","#E9E5F2"),border=NA)
text(.5,y,c("Two bulk tissue cohorts","Two single-cell cohorts","CRISPR and RNAi screens"),cex=.88)
par(mar=c(3.5,3.4,2.3,.8))
z <- subset(t,accession=="GSE149507")
z <- reshape(z[c("patient","tissue","CIP2A")],idvar="patient",timevar="tissue",direction="wide")
plot(NA,xlim=c(.7,2.3),ylim=range(z[-1]),xlab="",xaxt="n",ylab="CIP2A log2 expression")
axis(1,1:2,c("Lung","Tumor"))
segments(1,z$CIP2A.normal,2,z$CIP2A.tumor,col=adjustcolor(pal[1],.62))
ttl("B All 18 tissue pairs")
par(mar=c(2.9,.7,2.3,.6)); plot.new(); plot.window(xlim=c(0,1),ylim=c(0,1))
ttl("C Two concordant models")
text(c(.57,.89),.83,c("CRISPR","RNAi"),font=2,cex=.88)
models <- c("NCI-H211","DMS 53")
z <- r[match(models,r$model_name),]
for(i in 1:2){
y <- c(.59,.34)[i]
text(.01,y,models[i],adj=0,cex=.86)
text(c(.57,.89),y,sprintf("%.2f",c(z$chronos[i],z$dependency[i])),cex=.95,col=pal[2],font=2)
}
},height=63)