comparison report_clonality/RScript.r @ 34:f2010de70741 draft

Uploaded
author davidvanzessen
date Mon, 18 Jan 2016 07:55:31 -0500
parents 672d5e010b1f
children fd55088e48d2
comparison
equal deleted inserted replaced
33:2d38d7c1d0d0 34:f2010de70741
482 DJList = split(completeDJ, f=completeDJ[,"Sample"]) 482 DJList = split(completeDJ, f=completeDJ[,"Sample"])
483 lapply(DJList, FUN=plotDJ) 483 lapply(DJList, FUN=plotDJ)
484 } 484 }
485 485
486 486
487 # ---------------------- output tables for the circos plots ----------------------
488
489 print("Report Clonality - Circos data")
490
491 for(smpl in unique(PRODF$Sample)){
492 PRODF.sample = PRODF[PRODF$Sample == smpl,]
493
494 fltr = PRODF.sample$Top.V.Gene == ""
495 if(sum(fltr) > 0){
496 PRODF.sample[fltr, "Top.V.Gene"] = "NA"
497 }
498
499 fltr = PRODF.sample$Top.D.Gene == ""
500 if(sum(fltr) > 0){
501 PRODF.sample[fltr, "Top.D.Gene"] = "NA"
502 }
503
504 fltr = PRODF.sample$Top.J.Gene == ""
505 if(sum(fltr) > 0){
506 PRODF.sample[fltr, "Top.J.Gene"] = "NA"
507 }
508
509 v.d = table(PRODF.sample$Top.V.Gene, PRODF.sample$Top.D.Gene)
510 v.j = table(PRODF.sample$Top.V.Gene, PRODF.sample$Top.J.Gene)
511 d.j = table(PRODF.sample$Top.D.Gene, PRODF.sample$Top.J.Gene)
512
513 write.table(v.d, file=paste(smpl, "_VD_circos.txt", sep=""), sep="\t", quote=F, row.names=T, col.names=NA)
514 write.table(v.j, file=paste(smpl, "_VJ_circos.txt", sep=""), sep="\t", quote=F, row.names=T, col.names=NA)
515 write.table(d.j, file=paste(smpl, "_DJ_circos.txt", sep=""), sep="\t", quote=F, row.names=T, col.names=NA)
516 }
517
487 # ---------------------- calculating the clonality score ---------------------- 518 # ---------------------- calculating the clonality score ----------------------
488 519
489 if("Replicate" %in% colnames(inputdata)) #can only calculate clonality score when replicate information is available 520 if("Replicate" %in% colnames(inputdata)) #can only calculate clonality score when replicate information is available
490 { 521 {
522 print("Report Clonality - Clonality")
491 if(clonality_method == "boyd"){ 523 if(clonality_method == "boyd"){
492 samples = split(clonalityFrame, clonalityFrame$Sample, drop=T) 524 samples = split(clonalityFrame, clonalityFrame$Sample, drop=T)
493 525
494 for (sample in samples){ 526 for (sample in samples){
495 res = data.frame(paste=character(0)) 527 res = data.frame(paste=character(0))