comparison report_clonality/RScript.r @ 15:02efa5764a0a draft

Uploaded
author davidvanzessen
date Tue, 20 Dec 2016 08:36:12 -0500
parents 15961ca8d9ce
children da95be204ebc
comparison
equal deleted inserted replaced
14:15961ca8d9ce 15:02efa5764a0a
372 CDR3Length = data.frame(data.table(PRODF)[, list(Count=.N), by=c("Sample", "CDR3.Length")]) 372 CDR3Length = data.frame(data.table(PRODF)[, list(Count=.N), by=c("Sample", "CDR3.Length")])
373 TotalPerSample = data.frame(data.table(CDR3Length)[, list(total=sum(.SD$Count)), by=Sample]) 373 TotalPerSample = data.frame(data.table(CDR3Length)[, list(total=sum(.SD$Count)), by=Sample])
374 CDR3Length = merge(CDR3Length, TotalPerSample, by="Sample") 374 CDR3Length = merge(CDR3Length, TotalPerSample, by="Sample")
375 CDR3Length$Frequency = CDR3Length$Count * 100 / CDR3Length$total 375 CDR3Length$Frequency = CDR3Length$Count * 100 / CDR3Length$total
376 CDR3LengthPlot = ggplot(CDR3Length) 376 CDR3LengthPlot = ggplot(CDR3Length)
377 CDR3LengthPlot = CDR3LengthPlot + geom_bar(aes( x = CDR3.Length, y = Frequency, fill = Sample), stat='identity', position='dodge' ) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) + 377 CDR3LengthPlot = CDR3LengthPlot + geom_bar(aes( x = factor(reorder(CDR3.Length, as.numeric(CDR3.Length))), y = Frequency, fill = Sample), stat='identity', position='dodge' ) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
378 ggtitle("Length distribution of CDR3") + 378 ggtitle("Length distribution of CDR3") +
379 xlab("CDR3 Length") + 379 xlab("CDR3 Length") +
380 ylab("Percentage of sequences") + 380 ylab("Percentage of sequences") +
381 scale_fill_manual(values=sample.colors) + 381 scale_fill_manual(values=sample.colors) +
382 theme(panel.background = element_rect(fill = "white", colour="black"),text = element_text(size=15, colour="black"), axis.text.x = element_text(angle = 45, hjust = 1), panel.grid.major.y = element_line(colour = "black"), panel.grid.major.x = element_blank()) 382 theme(panel.background = element_rect(fill = "white", colour="black"),text = element_text(size=15, colour="black"), axis.text.x = element_text(angle = 45, hjust = 1), panel.grid.major.y = element_line(colour = "black"), panel.grid.major.x = element_blank())