Skip to content

Instantly share code, notes, and snippets.

View FloWuenne's full-sized avatar
💻

Florian Wuennemann FloWuenne

💻
View GitHub Profile
@FloWuenne
FloWuenne / find_specific_markers.R
Last active November 17, 2017 22:07 — forked from daskelly/find_specific_markers.R
Use Seurat to find specific markers of each cell type (modified from Dan Skelly)
library(tidyverse)
library(Seurat)
# Find specific markers for each cell type
# Find specific markers for each cell type
celltypes <- unique(expression_seurat_subset@ident) # list of cell types (unique ident labels of Seurat object)
obj <- expression_seurat_subset # Seurat object
specific_markers <- NULL
# First we do all pairwise comparisons and retain any markers that
@FloWuenne
FloWuenne / gist:d16cbb29c73ad469bbf10e42caac1fb7
Created November 14, 2017 15:03
Translate human to mouse gene symbols for cell cycling genes using biomart and save results for faster reading next time
# Basic function to convert human to mouse gene names
convertHumanGeneList <- function(x){
require("biomaRt")
human = useMart("ensembl", dataset = "hsapiens_gene_ensembl")
mouse = useMart("ensembl", dataset = "mmusculus_gene_ensembl")
genesV2 = getLDS(attributes = c("hgnc_symbol"), filters = "hgnc_symbol", values = x , mart = human, attributesL = c("mgi_symbol"), martL = mouse, uniqueRows=T)
humanx <- unique(genesV2[, 2])
@FloWuenne
FloWuenne / theme_Publication_custom.r
Last active November 16, 2017 19:09
Theme for publication quality graphs. Modified from https://rpubs.com/Koundy/71792!
##Plotting theme from (https://rpubs.com/Koundy/71792)
theme_Publication_custom <- function(base_size=14, base_family="helvetica") {
library(grid)
library(ggthemes)
(theme_foundation(base_size=base_size, base_family=base_family)
+ theme(plot.title = element_text(face = "bold",
size = rel(1.2), hjust = 0.5),
text = element_text(),
panel.background = element_rect(colour = NA),
plot.background = element_rect(colour = NA),
@FloWuenne
FloWuenne / gist:b4d1729b5ec2ceecfb4ce532e0fd8d67
Created November 22, 2017 14:35
Plot PCA for ethnicity from any given VCF file combined with 1000 genomes data
## Plot PCA for ethnicity of a given VCF file
## Import publication theme
## A nice R ggplot theme that I found online. Original can be found here:
## https://rpubs.com/Koundy/71792
theme_Publication <- function(base_size=14, base_family="helvetica") {
library(grid)
library(ggthemes)
(theme_foundation(base_size=base_size, base_family=base_family)
@FloWuenne
FloWuenne / gist:28349f097af6fbc4b7b5b4aa33bb6bc6
Created January 9, 2018 23:29
In Scenic analysis, identify all regulons that contain a gene of interest
## 3.0 contains all regulons that are considered for AUCell scoring
load("./int/3.0_regulons_forAUCell.RData")
## Define the gene you would like to find
gene_of_interest <- ""
## Iterates over all regulon names in regulons and searches the gene of interest inside the regulon.
for(reg in names(regulons)){
if(gene_of_interest %in% regulons[[reg]]){
@FloWuenne
FloWuenne / gist:f7de99c336facde90da36812cfc5b354
Last active March 8, 2018 00:58
Make a table of the number of cells for each group in the seurat object
```{r}
library(tidyr)
library(dplyr)
seurat_object <- seurat_objects.combined
grouping_var <- "Treatment"
cells_for_all_clusters <- data.frame()
#colnames(cells_for_all_clusters) <- c("WT","THC","CBS")
@FloWuenne
FloWuenne / gist:c4ab50836d577bbd32886959fd1f8f09
Created March 17, 2018 15:45
Quick testing of CIDR implementation
```{r}
## Read in some test data
colorectal <- readRDS("D:/Studies_PhD/Single_Cell_data/colorectal_cancer_Li_et_al_2017_SCESet.rds")
```
```{r}
sData <- scDataConstructor(as.matrix(colorectal))
sData <- determineDropoutCandidates(sData)
#sData <- wThreshold(sData)
@FloWuenne
FloWuenne / extract_shiny_data.R
Last active April 17, 2018 12:35
Create .Rdata file from Seurat object for clustering module of shiny server (for .Rdata)
library(dplyr)
library(tidyr)
time_point <- readline(prompt="Enter time point: ")
## Load Seurat object
seurat_object <- readRDS(paste("../Objects/",time_point,".Seurat_object.Rds",sep=""))
## Normalized expression data
norm_exprs_sparse <- seurat_object@data
@FloWuenne
FloWuenne / extract_ALL_shiny_data.R
Last active April 17, 2018 17:55
Extract data for clustering module from all time points (For .Rdata)
library(dplyr)
library(tidyr)
time_points <- c("E14.5","E16.5","E18.5","P1","P4","P7")
for(time_point in time_points){
## Load Seurat object
seurat_object <- readRDS(paste("../Objects/",time_point,".Seurat_object.Rds",sep=""))
@FloWuenne
FloWuenne / Create_clustering_module_Rds.R
Last active April 17, 2018 20:03
Create .Rds object with components needed for clustering module of heartmat shiny server (for .Rds)
library(dplyr)
library(tidyr)
## Define S4 object with required components
Clustering_info <- setClass("clustering_module",slots=c(tsne="data.frame",
metadata="data.frame",
norm_exprs="data.frame",
marker_list="data.frame"))
## Let user enter the time point to process