# #——回声= FALSE,结果=“隐藏”,消息= FALSE ------------------------------- 需要(knitr)美元opts_chunk组(错误= FALSE,消息= FALSE,警告= FALSE) # #设置,呼应= FALSE,消息= FALSE ----------------------------------------- 库(DropletUtils ) ## ----------------------------------------------------------------------------- # 生成的文件。例子(write10xCounts回声= FALSE) dir.name < - tmpdir list.files (dir.name ) ## ----------------------------------------------------------------------------- 南加州爱迪生公司< - read10xCounts南加州爱迪生公司(dir.name) ## ----------------------------------------------------------------------------- 类(计数(sce )) ## ----------------------------------------------------------------------------- set.seed (1000) mol.info.file < - DropletUtils::: simBasicMolInfo (tempfile ()) mol.info.file # #----------------------------------------------------------------------------- mol.info < - read10xMolInfo mol.info (mol.info.file) ## ----------------------------------------------------------------------------- set.seed(100)。- downsampleReads(mol.info.file, prop=1) sum(no.sampling) with。抽样< - downsampleReads (mol.info.file,道具= 0.5)和(with.sampling ) ## ----------------------------------------------------------------------------- set.seed(0)我的。计数< - DropletUtils::: simCounts () ## ----------------------------------------------------------------------------- br。out <- barcodeRanks(my.counts) #制作图形。情节(br。美元的地位,br。out$total, log="xy", xlab="Rank", ylab=" total ") o <- order(br.out$ Rank) lines(br. out$ Rank)美元地位[o], br。安装[o],美元=“红色”)abline上校(h =元数据(br.out) $膝盖,坳=“dodgerblue”,lty = 2) abline (h =元数据(br.out) $拐点,坳=“forestgreen”,lty = 2)传说(“bottomleft lty = 2,坳= c(“dodgerblue”、“forestgreen”),传说= c(“膝盖”、“拐点 ")) ## ----------------------------------------------------------------------------- set.seed (100) e.out < - emptyDrops e.out (my.counts) ## ----------------------------------------------------------------------------- 是多少。$FDR <= 0.01细胞,na.rm = TRUE ) ## ----------------------------------------------------------------------------- 表(有限= e。out$Limited, Significant=is.cell) ## ----------------------------------------------------------------------------- plot(e.out$Total, -e.out$LogProb, col=ifelse(is.cell, "red", "black"), xlab="Total UMI count", ylab="-Log Probability") ## ----------------------------------------------------------------------------- set.seed(10000) # Simulating empty droplets: nbarcodes <- 1000 nhto <- 10 y <- matrix(rpois(nbarcodes*nhto, 20), nrow=nhto) # Simulating cells: ncells <- 100 true.sample <- sample(nhto, ncells, replace=TRUE) y[cbind(true.sample, seq_len(ncells))] <- 1000 # Simulating doublets: ndoub <- ncells/10 next.sample <- (true.sample[1:ndoub] + 1) %% nrow(y) next.sample[next.sample==0] <- nrow(y) y[cbind(next.sample, seq_len(ndoub))] <- 500 ## ----------------------------------------------------------------------------- hto.calls <- emptyDrops(y, lower=500) has.cell <- hto.calls$FDR <= 0.001 summary(has.cell) ## ----------------------------------------------------------------------------- demux <- hashedDrops(y[,which(has.cell)], ambient=metadata(hto.calls)$ambient) demux ## ----------------------------------------------------------------------------- table(demux$Best[demux$Confident]) ## ----------------------------------------------------------------------------- colors <- ifelse(demux$Confident, "black", ifelse(demux$Doublet, "red", "grey")) plot(demux$LogFC, demux$LogFC2, col=colors, xlab="Log-fold change between best and second HTO", ylab="Log-fold change between second HTO and ambient") ## ----------------------------------------------------------------------------- set.seed(1000) mult.mol.info <- DropletUtils:::simSwappedMolInfo(tempfile(), nsamples=3) mult.mol.info ## ----------------------------------------------------------------------------- s.out <- swappedDrops(mult.mol.info, min.frac=0.9) length(s.out$cleaned) class(s.out$cleaned[[1]]) ## ----------------------------------------------------------------------------- out <- chimericDrops(mult.mol.info[1]) class(out) ## ----------------------------------------------------------------------------- sessionInfo()