Skip to content

Instantly share code, notes, and snippets.

@mikelove
Created May 18, 2016 14:39
Show Gist options
  • Save mikelove/a2b31758be89a3889a605de03bfe9d8b to your computer and use it in GitHub Desktop.
Save mikelove/a2b31758be89a3889a605de03bfe9d8b to your computer and use it in GitHub Desktop.
LA1 vs LB1
library(tximport)
txi <- tximport(c("LA1.sf","LB1.sf"), type="salmon", txOut=TRUE)
library(Homo.sapiens)
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
txdf <- select(txdb, keys(txdb, "GENEID"), "TXID", "GENEID")
txdf$REFSEQ <- mapIds(Homo.sapiens, as.character(txdf$TXID), "REFSEQ", "TXID")
tab <- table(txdf$GENEID)
txdf$numiso <- tab[txdf$GENEID]
txdf2 <- txdf[txdf$REFSEQ %in% rownames(txi$abundance),]
a <- sapply(1:10, function(i) sum(txi$abundance[txdf2$REFSEQ[txdf2$numiso == i],1]))
b <- sapply(1:10, function(i) sum(txi$abundance[txdf2$REFSEQ[txdf2$numiso == i],2]))
d <- data.frame(sumTPM=c(a,b), numiso=factor(c(1:10,1:10)), sample=rep(c("A","B"),each=10))
library(ggplot2)
ggplot(d, aes(x=numiso,y=sumTPM,fill=sample)) + geom_bar(stat="identity", position="dodge")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment