knitr::opts_chunk$set(echo = TRUE)
library(conos)
require(pagoda2)
library(fuck)
library(pheatmap)
panel <- readRDS(file.path('/home/larsc/pancreas_smart_seq_cms.rds'))
annot <- readRDS(file.path('/home/larsc/pancreas_smart_seq_design_info.rds'))

quick count of cells

panel %>% lapply(dim) %>% lapply(`[`, i = 2) %>% Reduce(sum,.)

pre proc

panel.preprocessed <- lapply(panel, basicP2proc, n.cores=25, min.cells.per.gene=0, n.odgenes=2e3, get.largevis=FALSE, make.geneknn=FALSE)

make conos object

con <- Conos$new(panel.preprocessed, n.cores=1)
con$plotPanel(clustering="multilevel", use.local.clusters=T, title.size=6)
con$buildGraph(k=15, k.self=10, k.self.weight=0.1, space='PCA', ncomps=50, n.odgenes=2000, matching.method='mNN', metric='angular', verbose=TRUE)
con$findCommunities(method=multilevel.community, min.group.size=0)
con$plotPanel(font.size=4)
cellannot=as.data.frame(annot[,c(1,8)])
cellannot <- setNames(cellannot[,2],cellannot[,1])
con$plotPanel(groups = cellannot,font.size=3)
disannot=as.data.frame(annot[,c(1,9)])
disannot_names <- setNames(disannot[,2],disannot[,1])
con$plotPanel(groups = disannot_names,font.size=2)
con$plotGraph(groups=disannot_names)

DE

samplegroups <- CreateSampleGroups(annot, 9, 6)
de.multilevel <- getPerCellTypeDE(con, groups=as.factor(cellannot),sample.groups = samplegroups, ref.level='normal', n.cores=1)
head(de.multilevel$`acinar cell`$res)
mostvar = fuck::GetMostvar(de.multilevel, 15)

heatmap

con$plotGraph(groups=cellannot)
con$plotGraph(gene = "PRSS1")

filter annotation

annot_filter <- fuck::FilterAnnot(con, annot, 1)
subtype_exps <- fuck::GetSubtypeExp(con, mostvar, annot_filter, 8, 1)
pheatmap(mat = subtype_exps,clustering_distance_cols = 'euclidean', clustering_distance_rows = 'euclidean') 


githubz0r/fuck documentation built on May 15, 2019, 10:39 p.m.