comparison report_clonality/RScript.r @ 20:9185c3dfc679 draft

Uploaded
author davidvanzessen
date Fri, 27 Jan 2017 03:44:18 -0500
parents 5d11c9139a55
children d5d203d38c8a
comparison
equal deleted inserted replaced
19:3ef457aa5df6 20:9185c3dfc679
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 598
599 write.table(res, file=paste("raw_clonality_", sample_id, ".csv", sep=""), sep=",",quote=F,row.names=F,col.names=F) 599 write.table(res, file=paste("raw_clonality_", sample_id, ".txt", sep=""), sep="\t",quote=F,row.names=F,col.names=F)
600 write.table(as.matrix(res[,2:ncol(res)]), file=paste("raw_clonality2_", sample_id, ".txt", sep=""), sep="\t",quote=F,row.names=F,col.names=F)
601
602 res = read.table(paste("raw_clonality_", sample_id, ".txt", sep=""), header=F, sep="\t", quote="", stringsAsFactors=F, fill=T, comment.char="")
600 603
601 infer.result = infer.clonality(as.matrix(res[,2:ncol(res)])) 604 infer.result = infer.clonality(as.matrix(res[,2:ncol(res)]))
602 605
603 #print(infer.result) 606 #print(infer.result)
604 607
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) 608 write.table(data.table(infer.result[[12]]), file=paste("lymphclon_clonality_", sample_id, ".txt", sep=""), sep="\t",quote=F,row.names=F,col.names=F)
606 609
607 res$type = rowSums(res[,2:ncol(res)]) 610 res$type = rowSums(res[,2:ncol(res)])
608 611
609 coincidence.table = data.frame(table(res$type)) 612 coincidence.table = data.frame(table(res$type))
610 colnames(coincidence.table) = c("Coincidence Type", "Raw Coincidence Freq") 613 colnames(coincidence.table) = c("Coincidence Type", "Raw Coincidence Freq")
611 write.table(coincidence.table, file=paste("lymphclon_coincidences_", sample_id, ".csv", sep=""), sep=",",quote=F,row.names=F,col.names=T) 614 write.table(coincidence.table, file=paste("lymphclon_coincidences_", sample_id, ".txt", sep=""), sep="\t",quote=F,row.names=F,col.names=T)
612 } 615 }
613 } else if(clonality_method == "old") { 616 } else if(clonality_method == "old") {
614 clonalFreq = data.frame(data.table(clonalityFrame)[, list(Type=.N), by=c("Sample", "clonaltype")]) 617 clonalFreq = data.frame(data.table(clonalityFrame)[, list(Type=.N), by=c("Sample", "clonaltype")])
615 618
616 #write files for every coincidence group of >1 619 #write files for every coincidence group of >1