# #——scTensor NCBI基因ID, eval = FALSE ----------------------------------- # 库(scTensor) #库(AnnotationHub) #库(LRBaseDbi) # # # #输入矩阵输入< -…# sce <- singlecel实验(assays=list(counts = input)) # # Celltype vector # label <-# # LRBase.XXX.eg.db #啊< - AnnotationHub () # dbfile < -查询(啊,c(“LRBaseDb”、“智人”,“v002”))([1])# LRBase.Hsa.eg.db < - LRBaseDbi:: LRBaseDb (dbfile) # # #设置cellCellSetting (sce、LRBase.Hsa.eg.db标签)# #——修,eval = FALSE ------------------------------------------------------- # 如果(!需要(修)){# BiocManager::安装(“修”)#库(修 ) # } # # # 数据集加载PBMC # PBMC。数据<- Read10X(数据。dir = "filtered_gene_bc_matrices/hg19/")# pbmc <- CreateSeuratObject(counts = pbmc.)data, # project = "pbmc3k", min.cells = 3, min.features = 200) ## ----Ensembl with Organism DB, echo=TRUE-------------------------------------- suppressPackageStartupMessages(library("scTensor")) if(!require(Homo.sapiens)){BiocManager::install("Homo.sapiens") suppressPackageStartupMessages(library(" scTGIF"))} if(!require(scTGIF)){BiocManager::install("scTGIF") suppressPackageStartupMessages(library(scTGIF))}输入矩阵Input <- matrix(1:20, nrow=4, ncol=5) # 2。3.每一行基因标识符rowID <- c("ENSG00000204531", "ENSG00000181449", "ENSG00000136997", "ENSG00000136826") # 3。对应表LefttoRight <- select(Homo。sapiens, column=c("ENSEMBL", "ENTREZID"), keytype="ENSEMBL", keys=rowID) # ID转换(input <- convertRowID(input, rowID, LefttoRight)) ## ---- ENSEMBL with AnnotationHub, echo=TRUE------------------------------------ suppressPackageStartupMessages(library("AnnotationHub")) # 1。 Input matrix input <- matrix(1:20, nrow=4, ncol=5) # 3. Corresponding table ah <- AnnotationHub() # Database of Human hs <- query(ah, c("OrgDb", "Homo sapiens"))[[1]] LefttoRight <- select(hs, column=c("ENSEMBL", "ENTREZID"), keytype="ENSEMBL", keys=rowID) (input <- convertRowID(input, rowID, LefttoRight)) ## ----Gene Symbol with Organism DB, echo=TRUE---------------------------------- # 1. Input matrix input <- matrix(1:20, nrow=4, ncol=5) # 2. Gene identifier in each row rowID <- c("POU5F1", "SOX2", "MYC", "KLF4") # 3. Corresponding table LefttoRight <- select(Homo.sapiens, column=c("SYMBOL", "ENTREZID"), keytype="SYMBOL", keys=rowID) # ID conversion (input <- convertRowID(input, rowID, LefttoRight)) ## ----Gene Symbol with AnnotationHub, echo=TRUE-------------------------------- # 1. Input matrix input <- matrix(1:20, nrow=4, ncol=5) # 3. Corresponding table ah <- AnnotationHub() # Database of Human hs <- query(ah, c("OrgDb", "Homo sapiens"))[[1]] LefttoRight <- select(hs, column=c("SYMBOL", "ENTREZID"), keytype="SYMBOL", keys=rowID) (input <- convertRowID(input, rowID, LefttoRight)) ## ----Seurat normalization, eval=FALSE----------------------------------------- # pbmc2 <- NormalizeData(pbmc, normalization.method = "LogNormalize", # scale.factor = 10000) # sce <- as.SingleCellExperiment(pbmc2) # assayNames(sce) # counts, logcounts ## ----Scater normalization, eval=FALSE----------------------------------------- # if(!require(scater)){ # BiocManager::install("scater") # library(scater) # } # sce <- SingleCellExperiment(assays=list(counts = input)) # cpm(sce) <- calculateCPM(sce) # sce <- normalize(sce) # assayNames(sce) # counts, normcounts, logcounts, cpm ## ----Original normalization, eval=FALSE--------------------------------------- # # User's Original Normalization Function # CPMED <- function(input){ # libsize <- colSums(input) # median(libsize) * t(t(input) / libsize) # } # # Normalization # normcounts(sce) <- log10(CPMED(counts(sce)) + 1) ## ----sessionInfo, echo=FALSE-------------------------------------------------- sessionInfo()