Skip to content

Instantly share code, notes, and snippets.

View daskelly's full-sized avatar

Dan Skelly daskelly

View GitHub Profile
@daskelly
daskelly / bitbucket2github.md
Created June 20, 2017 17:17
Migrating from bitbucket to github

Migrating from bitbucket to github

When migrating a repo from bitbucket to github, I like to take a simple and straightforward approach:

git remote set-url origin git@github.com:USERNAME/REPONAME.git

This example assumes that a remote branch named origin points to bitbucket, and you are resetting that URL to now point to github. Then you can git push to github.

@daskelly
daskelly / download.sh
Created July 11, 2017 18:38
cURL follow redirect
curl -O -L https://github.com/iontorrent/TS/archive/TorrentSuite_5.2.2-sp1.tar.gz
@daskelly
daskelly / render.pbs
Last active September 5, 2017 01:48
Render an R markdown document on a PBS/Torque cluster
#!/bin/bash
#PBS -N name
#PBS -l nodes=1:ppn=1,mem=10gb,walltime=6:00:00
#PBS -m n
#PBS -j oe
#PBS -r n
module load R/3.3.2 gcc/4.9.2
module load pandoc/1.13.1
mini <- matrix(rnorm(4000*50), nrow=4000, ncol=50)
system.time(M <- cor(t(mini), t(mini), method='pearson'))
fastcorr <- function(x) {
# fast correlation between rows of x
# from http://stackoverflow.com/questions/18964837/fast-correlation-in-r-using-c-and-parallelization
if (!is.matrix(x)) x <- as.matrix(x)
x <- x - rowMeans(x)
x <- x/sqrt(rowSums(x^2))
tcrossprod(x)
@daskelly
daskelly / find_specific_markers.R
Last active April 5, 2018 18:40
Use Seurat to find specific markers of each cell type
library(tidyverse)
library(Seurat)
# Find specific markers for each cell type
celltypes <- # list of cell types (unique ident labels of Seurat object)
obj <- # Seurat object
specific_markers <- NULL
# First we do all pairwise comparisons and retain any markers that
# are even somewhat higher in the cell type of interest
@daskelly
daskelly / install_mosh_locally.sh
Last active August 6, 2021 19:34 — forked from lazywei/install_mosh_locally.sh
Install mosh server without root permission
#!/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
@daskelly
daskelly / conda_leafcutter.sh
Last active March 10, 2018 23:17
Using conda to install leafcutter
# 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
@daskelly
daskelly / filter_cell_surface.r
Created August 20, 2018 18:11
code to filter genes to find those expressed on cell surface
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"),
@daskelly
daskelly / find_specific_markers_parallel.R
Last active November 30, 2018 17:57
parallel version of find_specific_markers.R
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
@daskelly
daskelly / read10x
Created December 18, 2018 15:23
Version of Seurat's Read10X function for 10X cellranger 3 data
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]))