Skip to content

Instantly share code, notes, and snippets.

@rahulbhadani
Last active August 3, 2020 06:00
Show Gist options
  • Save rahulbhadani/88bac7b81cee0368ad62d229d2788532 to your computer and use it in GitHub Desktop.
Save rahulbhadani/88bac7b81cee0368ad62d229d2788532 to your computer and use it in GitHub Desktop.
Using scDoc Imputation
# Installing scDoc from source
install.packages("https://github.com/anlingUA/scDoc/blob/master/scDoc_0.0.0.9.tar.gz?raw=true", repo=NULL, type="source")
library(scDoc)
data(zebrafish)
# Used when estimating dropout
offsets <- as.numeric(log(colSums(zebrafish)))
# Filtering step
count <- zebrafish[rowSums(zebrafish > 5) > 4, ]
# # matrix of dropout probability, Takes about 2 minutes to run w/3 cores
dp.mat <- prob.dropout(input = count, is.count = TRUE, offsets = offsets, mcore = 3)
# Similarity matrix, About 1 minute to run w/3 cores
sim.mat <- sim.calc(log2(count+1), dp.mat)
# As input, requires raw count matrix and "dmat" matrix
# containing dropout probability (from using prob.dropout),
# plus "sim.mat" matrix containing cell-to-cell similarity
# (from using sim.mat)
impute.mat <- impute.knn(input = count, dmat = dp.mat, sim.mat = sim.mat, k = 5, sim.cut = 1e-4)
# This is the finished, imputed data
target.g = impute.mat$output.im
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment