comparison report_clonality/RScript.r @ 17:da95be204ebc draft

Uploaded
author davidvanzessen
date Wed, 21 Dec 2016 05:57:31 -0500
parents 02efa5764a0a
children 5d11c9139a55
comparison
equal deleted inserted replaced
16:21ca9391a3b7 17:da95be204ebc
592 clone_col_name = paste("V", replicate, sep="") 592 clone_col_name = paste("V", replicate, sep="")
593 colnames(clone_table) = c("paste", clone_col_name) 593 colnames(clone_table) = c("paste", clone_col_name)
594 res = merge(res, clone_table, by="paste", all=T) 594 res = merge(res, clone_table, by="paste", all=T)
595 } 595 }
596 596
597 res[is.na(res)] = 0 597 res[is.na(res)] = 0
598
599 write.table(res, file=paste("raw_clonality_", sample_id, ".csv", sep=""), sep=",",quote=F,row.names=F,col.names=F)
600
598 infer.result = infer.clonality(as.matrix(res[,2:ncol(res)])) 601 infer.result = infer.clonality(as.matrix(res[,2:ncol(res)]))
599 602
600 #print(infer.result) 603 #print(infer.result)
601 604
602 write.table(data.table(infer.result[[12]]), file=paste("lymphclon_clonality_", sample_id, ".csv", sep=""), sep=",",quote=F,row.names=F,col.names=F) 605 write.table(data.table(infer.result[[12]]), file=paste("lymphclon_clonality_", sample_id, ".csv", sep=""), sep=",",quote=F,row.names=F,col.names=F)
605 608
606 coincidence.table = data.frame(table(res$type)) 609 coincidence.table = data.frame(table(res$type))
607 colnames(coincidence.table) = c("Coincidence Type", "Raw Coincidence Freq") 610 colnames(coincidence.table) = c("Coincidence Type", "Raw Coincidence Freq")
608 write.table(coincidence.table, file=paste("lymphclon_coincidences_", sample_id, ".csv", sep=""), sep=",",quote=F,row.names=F,col.names=T) 611 write.table(coincidence.table, file=paste("lymphclon_coincidences_", sample_id, ".csv", sep=""), sep=",",quote=F,row.names=F,col.names=T)
609 } 612 }
610 } else { 613 } else if(clonality_method == "old") {
611 clonalFreq = data.frame(data.table(clonalityFrame)[, list(Type=.N), by=c("Sample", "clonaltype")]) 614 clonalFreq = data.frame(data.table(clonalityFrame)[, list(Type=.N), by=c("Sample", "clonaltype")])
612 615
613 #write files for every coincidence group of >1 616 #write files for every coincidence group of >1
614 samples = unique(clonalFreq$Sample) 617 samples = unique(clonalFreq$Sample)
615 for(sample in samples){ 618 for(sample in samples){