Skip to content

Instantly share code, notes, and snippets.

View dfjenkins3's full-sized avatar

David Jenkins dfjenkins3

View GitHub Profile
@dfjenkins3
dfjenkins3 / createSCTKE_from_Rsubread_and_multiqc.R
Created July 25, 2018 20:40
Create SCTKE from Rsubread and multiqc
library(singleCellTK)
createSCTKE_from_Rsubread_and_multiqc <- function(matdir, r1multi, r2multi){
r1annot <- read.table(r1multi, sep="\t", row.names = 1, header=TRUE)
colnames(r1annot) <- paste0(colnames(r1annot), "_R1")
rownames(r1annot) <- gsub("_R1$", "", rownames(r1annot))
r2annot <- read.table(r2multi, sep="\t", row.names = 1, header=TRUE)
colnames(r2annot) <- paste0(colnames(r2annot), "_R2")
rownames(r2annot) <- gsub("_R2$", "", rownames(r2annot))
if(any(rownames(r1annot)!=rownames(r2annot))){
@dfjenkins3
dfjenkins3 / cellranger_dir_to_sctke.R
Last active June 7, 2018 17:54
Convert Cell Ranger outs Directory to a SingleCelltkExperiment
#' Convert Cell Ranger outs Directory to a SingleCelltkExperiment
#'
#' This function creates a SingleCelltkExperiment object from a Cell Ranger
#' output directory. The filtered count matrix, pca, tsne, and clustering
#' results are stored in the object. This function requires the cellrangerRkit
#' package which is not on CRAN or Bioconductor. Install it using the directions
#' available here:
#'
#' https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/rkit
#'
@dfjenkins3
dfjenkins3 / runlimma.R
Created May 11, 2017 19:28
Simple Limma Function
library(limma)
library(edgeR)
# function to return the toptable from limma
# indata: raw count matrix for all kras comparisons
# subsetcols: column indices for columns that you want to subset
# firstannot: the name of the first annotation
# secondannot: the name of the second annotation
get_toptable <- function(indata, subsetcols, firstannot, secondannot){
subset_gfp_wt <- indata[,subsetcols]
@dfjenkins3
dfjenkins3 / read10x.R
Created May 5, 2017 20:44
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)
@dfjenkins3
dfjenkins3 / code.R
Last active April 30, 2017 20:21
Example ComplexHeatmap
create_complexheatmap <- function(indata){
set.seed(123)
sample.annotation <- data.frame(SampleType=sample(c("groupA","groupB"),
size = ncol(indata),
replace = TRUE))
topha <- HeatmapAnnotation(df = sample.annotation,
col = list(SampleType = c("groupA" = "coral3",
"groupB" = "aquamarine4")),
@dfjenkins3
dfjenkins3 / hist_widget.R
Last active April 18, 2017 21:08
Shiny Widget Example
library(shiny)
hist_widget <- function() {
shinyApp(
ui = fluidPage(
sidebarLayout(
sidebarPanel(sliderInput("n", "Bins", 5, 100, 20)),
mainPanel(plotOutput("hist"))
)
),
@dfjenkins3
dfjenkins3 / keybase.md
Created April 5, 2017 17:31
keybase.md

Keybase proof

I hereby claim:

  • I am dfjenkins3 on github.
  • I am dfjenkins3 (https://keybase.io/dfjenkins3) on keybase.
  • I have a public key whose fingerprint is 596F 88F4 BA92 A8AE BB47 7D84 8916 F2F3 B5CA 1207

To claim this, I am signing this object:

@dfjenkins3
dfjenkins3 / pca.R
Created May 25, 2016 16:47
example PCA
#run PCA
pca.results <- prcomp(t(expression))
#vector of colors
cols <- as.character(indata$Annotation)
cols[cols=="K"] <- 'red'
cols[cols=="LG"] <- 'lightgreen'
cols[cols=="G"] <- 'darkgreen'
#plot it
@dfjenkins3
dfjenkins3 / compare_tggates_drugmatrix.md
Created December 17, 2015 20:44
Comparing GenTox with Bacterial.Mutagenesis

Comparing GenTox with Bacterial.Mutagenesis

library(Biobase)

setwd(file.path("C:","Users","djenk","OneDrive","grad_school","05-2015_fall",
                "BS830_microarray","20151218-Final_Project"))

#TG-GATEs Data (Discovery Set)
@dfjenkins3
dfjenkins3 / compare_tggates_drugmatrix.Rmd
Created December 17, 2015 20:43
Comparing GenTox with Bacterial.Mutagenesis
# Comparing GenTox with Bacterial.Mutagenesis
```{r}
library(Biobase)
setwd(file.path("C:","Users","djenk","OneDrive","grad_school","05-2015_fall",
"BS830_microarray","20151218-Final_Project"))
#TG-GATEs Data (Discovery Set)
load("Rat.Liver.in_vivo.repeat.annotated.RData")