Skip to content

Instantly share code, notes, and snippets.

View jebard's full-sized avatar

Jonathan Bard jebard

View GitHub Profile
library(Seurat)
## Prep for 10x loupe browser inegration
seurat.object
### first we need to extract out the seurat cell barcodes and convert them back into Loupe space
### note this is tested on integrated objects in seurat with multi samples
seurat.object$loupe_barcodes <- gsub(names(Idents(seurat.object)),pattern = "-1_",replacement = "-")
## pull the embeddings from UMAP
embeds <- (seurat.object@reductions$umap@cell.embeddings)
#!/usr/bin/python
import pysam
import numpy as np
import deeptools.mapReduce
import csv
import argparse
#Tb927_10_v5.1:3648504-3654301 #Tb927.10.14930
#Tb927_10_v5.1:3648504-3654301 (+)
@jebard
jebard / Seurat and Phate
Last active January 4, 2024 16:14
Seurat to Phate to Seurat
### handles the Seurat to phate conversio
### first, grab the input required for phate (here we are using the normalized data stored in Seurat
seurat_data <- as.data.frame(seurat.object@assays$RNA@data)
## reshape for input into PHATE
phate_data_input <- t(seurat_data)
## run phate -- this is a default run, feel free to tune params
wt.subset <- subset(immune.combined, subset = stim == c("CTRL"))
ko.subset <- subset(immune.combined, subset = stim == c("Trp63-"))
FeaturePlot(immune.combined,features = c("Foxi2","Foxc1"),split.by = "stim")
gg1 <- plot_split_by_feature(wt.subset,ko.subset,c("Foxi2"))
gg2 <- plot_split_by_feature(wt.subset,ko.subset,c("Foxc1"))
ggsave(file="Foxi2_Foxc1.png",plot_grid(gg1,gg2,ncol=1))
plot_split_by_feature<- function(wildType, knockout, feature ) {
ptSize = .4
@jebard
jebard / Seurat_to_velocyto.R
Created November 14, 2018 15:13
Seurat to Veloctyo Code -- This is a general code chunk for running Velocyto on a Seurat object generated with 10x single-cell sequencing data.
library(velocyto.R)
library(pagoda2)
library(Seurat)
### ASSUMES Seurat object has already been computed -- in this case the object cells.combined is the result of seurat
# IMPORTANT!!! create a loom file using the velocyto command line tools first
ldat <- read.loom.matrices("filtered.loom")
# get the spliced and unspliced ratios from the loom file