Skip to content

Instantly share code, notes, and snippets.

@dfjenkins3
Created May 5, 2017 20:44
Show Gist options
  • Save dfjenkins3/a549a439c5bf178c2b0f722e97f5f6ee to your computer and use it in GitHub Desktop.
Save dfjenkins3/a549a439c5bf178c2b0f722e97f5f6ee to your computer and use it in GitHub Desktop.
Using cellrangerRkit to read in 10X genomics results in R
#credit to @myajima
library(cellrangerRkit) #install using https://s3-us-west-2.amazonaws.com/10x.files/supp/cell-exp/rkit-install-1.1.0.R
pipestance_path <-getwd()
download_sample(sample_name="pbmc3k",
sample_dir=pipestance_path,
host="https://s3-us-west-2.amazonaws.com/10x.files/samples/cell/")
gbm <- load_cellranger_matrix(pipestance_path)
analysis_results <-load_cellranger_analysis_results(pipestance_path)
use_genes <- get_nonzero_genes(gbm)
gbm_bcnorm <- normalize_barcode_sums_to_median(gbm[use_genes,])
gbm_log <- log_gene_bc_matrix(gbm_bcnorm,base=10)
use_genes <- which(rowSums(exprs(gbm_log)>0)>100)
cmatp<-exprs(gbm_bcnorm)[use_genes,]
library(pheatmap)
pdf("heatmap.pdf")
pheatmap(log(cmatp))
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment