This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(Seurat) | |
library(harmony) | |
# x is a Seurat object not yet processed but we have chosen num_pc | |
x <- FindNeighbors(x, reduction = 'pca', dims = 1:num_pc, verbose = FALSE) %>% | |
FindClusters(verbose = FALSE, resolution = 0.2) %>% | |
RunUMAP(reduction = 'pca', dims = 1:num_pc, verbose = FALSE) | |
x$noharmony_clusters <- x$seurat_clusters | |
x@misc$noharmony_umap <- x@reductions$umap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(DT) | |
# | |
# make a table of results | |
# ... | |
# | |
datatable(signif_results, filter = 'top', rownames = FALSE, | |
options=list(pageLength = 10, autoWidth = TRUE)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ensembldb) | |
library(EnsDb.Mmusculus.v79) | |
ensembl_gene_ids <- c('ENSMUSG00000000120', 'ENSMUSG00000000159', 'ENSMUSG00000000563', 'ENSMUSG00000000600') # some random IDs | |
ensembldb::select(EnsDb.Mmusculus.v79, keys=ensembl_gene_ids, keytype = "GENEID", columns = c("SYMBOL","GENEID")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List all open tabs in front Chrome window | |
# From https://superuser.com/questions/276321/how-to-export-opened-tabs-in-chrome | |
alias listtabs="osascript -e{'set o to\"\"','tell app\"google chrome\"','repeat with t in tabs of window 1','set o to o&url of t&\" \"&title of\ | |
t&linefeed',end,end}|sed \$d" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wilcox_unequal_var <- function(x, y, ...) { | |
# The Wilcoxon rank sum test (Mann Whitney U test) does not perform | |
# that well on data where the variances are unequal. Some | |
# investigators have recommended as an alternative performing the | |
# unequal variance t-test on ranked values. See | |
# https://academic.oup.com/beheco/article/17/4/688/215960 | |
# https://psycnet.apa.org/doiLanding?doi=10.1037%2Fh0078850 | |
rr <- rank(c(x, y)) | |
nx <- length(x) | |
t.test(rr[1:nx], rr[(nx+1):length(rr)], var.equal=FALSE, ...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read10x <- function(dir) { | |
names <- c("barcodes.tsv", "features.tsv", "matrix.mtx") | |
for (i in 1:length(names)) { | |
R.utils::gunzip(paste0(dir, "/", names[i], ".gz")) | |
} | |
file.copy(paste0(dir, "/features.tsv"), paste0(dir, "/genes.tsv")) | |
mat <- Seurat::Read10X(dir) | |
file.remove(paste0(dir, "/genes.tsv")) | |
for (i in 1:length(names)) { | |
R.utils::gzip(paste0(dir, "/", names[i])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(Seurat) | |
library(doParallel) | |
# Find specific markers for each cell type | |
n.cores <- 10 | |
registerDoParallel(cores=n.cores) | |
celltypes <- # list of cell types (unique ident labels of Seurat object) | |
obj <- # Seurat object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(biomaRt) | |
genes <- # FILL ME IN ... Should be a vector of gene names | |
markers <- # FILL ME IN ... Should be a data.frame with at least one column called mgi_symbol | |
ensembl <- useMart("ensembl", dataset="mmusculus_gene_ensembl") # Mouse | |
# GO:0009986 is cell surface | |
go_cellsurf <- "GO:0009986" | |
gene.data <- getBM(attributes=c("mgi_symbol", "ensembl_gene_id", "go_id"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Intalling leafcutter on a CentOS 6.5 machine | |
# This machine has glibc 2.12 and leafcutter needs glibc 2.14 | |
module purge | |
module load gcc/4.9.2 | |
# Install glibc 2.14 | |
mkdir $HOME/apps/glibc_install | |
cd $HOME/apps/glibc_install | |
wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz | |
tar zxvf glibc-2.14.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# works on a machine running CentOS 7.7 | |
# no error checking and this requires manual intervention. This script just gives | |
# an overview of the process. | |
# | |
# https://github.com/rust-lang/cargo/issues/713 was helpful... | |
mkdir -p apps/mosh | |
cd apps/mosh |
NewerOlder