Skip to content

Instantly share code, notes, and snippets.

@hussius
Created September 14, 2015 07:52
Show Gist options
  • Save hussius/e1d9900f931bd0e61629 to your computer and use it in GitHub Desktop.
Save hussius/e1d9900f931bd0e61629 to your computer and use it in GitHub Desktop.
Sleuth commands
# Installation (only needs to be done once)
source("http://bioconductor.org/biocLite.R")
biocLite("rhdf5")
install.packages("devtools")
devtools::install_github("pachterlab/sleuth")
# Now load the package
library("sleuth")
# A function (borrowed from the Sleuth documentation) for connecting Ensembl transcript names to common gene names
tx2gene <- function(){
mart <- biomaRt::useMart(biomart = "ensembl", dataset = "hsapiens_gene_ensembl")
t2g <- biomaRt::getBM(attributes = c("ensembl_transcript_id", "ensembl_gene_id",
"external_gene_name"), mart = mart)
t2g <- dplyr::rename(t2g, target_id = ensembl_transcript_id,
ens_gene = ensembl_gene_id, ext_gene = external_gene_name)
return(t2g)
}
t2g <- tx2gene()
base_dir <- "PATH/TO/YOUR/FOLDER" # replace with path to the directory where your Kallisto output folders are
samples <- c("SRR057629","SRR057630","SRR057632","SRR057649","SRR057650","SRR057651")
# Fill in metadata about the samples. In this case pretend we just know it, rather than fetching metadata from SRA
s2c <- data.frame(sample=samples,individual=as.factor(rep(c(2,3,6),2)), condition=c(rep("tumor",3),rep("normal",3)))
kal_dirs <- sapply(samples, function(id) file.path(base_dir, id))
# The command below will read the Kallisto output files and connect them with metadata + assume a linear model
so <- sleuth_prep(kal_dirs, s2c, ~individual+condition, target_mapping = t2g)
# Fit the model
so <- sleuth_fit(so)
# Test for one of the model coefficients, in this case condition
so <- sleuth_test(so, which_beta = 'conditiontumor')
# Visualize the results
sleuth_live(so)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment