diff --git a/DESCRIPTION b/DESCRIPTION index c8c8a8e..e6c6212 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: scTensor Type: Package Title: Detection of cell-cell interaction from single-cell RNA-seq dataset by tensor decomposition -Version: 2.3.3 +Version: 2.4.1 Authors@R: c(person("Koki", "Tsuyuzaki", role = c("aut", "cre"), email = "k.t.the-answer@hotmail.co.jp"), person("Kozo", "Nishida", role = "aut", @@ -16,9 +16,9 @@ Imports: methods, AnnotationDbi, SummarizedExperiment, SingleCellExperiment, - nnTensor, - ccTensor, - rTensor, + nnTensor (>= 1.1.5), + ccTensor (>= 1.0.2), + rTensor (>= 1.4.8), abind, plotrix, heatmaply, @@ -27,14 +27,14 @@ Imports: methods, BiocStyle, knitr, AnnotationHub, - MeSHDbi, + MeSHDbi (>= 1.29.2), grDevices, graphics, stats, utils, outliers, Category, - meshr, + meshr (>= 1.99.1), GOstats, ReactomePA, DOSE, diff --git a/NAMESPACE b/NAMESPACE index 957446e..5715d30 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -40,8 +40,8 @@ importFrom("utils", "data") importFrom("grDevices", "hcl") importFrom(visNetwork, visNetwork) -importFrom(schex, make_hexbin, plot_hexbin_gene) +importFrom(schex, make_hexbin, plot_hexbin_feature) importFrom(ggplot2, scale_fill_gradient, ggsave) exportMethods(cellCellSetting, cellCellRanks, cellCellDecomp, cellCellReport, getParam, "setParam<-") -export(cellCellSimulate, newCCSParams, convertToNCBIGeneID) \ No newline at end of file +export(cellCellSimulate, newCCSParams) \ No newline at end of file diff --git a/R/AllGenerics.R b/R/AllGenerics.R index f601c6a..2a6b54e 100644 --- a/R/AllGenerics.R +++ b/R/AllGenerics.R @@ -68,6 +68,7 @@ setMethod("cellCellSetting", signature(sce="SingleCellExperiment"), } # Overwrite metadata(sce) <- list(lrbase=lrbase$conn@dbname, + ahid=names(lrbase$dbfile), lr.evidence=lr.evidence, label=label, color=color) assign(userobjects, sce, envir=.GlobalEnv) } @@ -104,7 +105,6 @@ setMethod("cellCellRanks", if(num.iter2 < 0){ stop("Please specify the num.iter2 as positive integer") } - # Import from sce object sce <- list(...)[[1]] # Import expression matrix @@ -114,12 +114,10 @@ setMethod("cellCellRanks", celltypes <- metadata(sce)$color names(celltypes) <- metadata(sce)$label l <- length(unique(celltypes)) - # Tensor is generated tnsr <- .cellCellDecomp.Third(input, LR, celltypes, ranks=c(1,1,1), rank=1, centering, mergeas, outerfunc, comb, num.sampling, num.perm, decomp=FALSE, thr1=log2(5), thr2=25, thr3=0.95, verbose)$cellcelllrpairpattern - # Limit l1 <- min(dim(tnsr)[1], dim(tnsr)[2]*dim(tnsr)[3]) l2 <- min(dim(tnsr)[2], dim(tnsr)[3]*dim(tnsr)[1]) @@ -252,7 +250,8 @@ setMethod("cellCellDecomp", signature(sce="SingleCellExperiment"), # Overwrite metadata(sce) <- list(lrbase=metadata(sce)$lrbase, - lr.evidence=lr.evidence, + ahid=metadata(sce)$ahid, + lr.evidence=metadata(sce)$lr.evidence, color=metadata(sce)$color, label=metadata(sce)$label, algorithm=algorithm, sctensor=res.sctensor, ranks=ranks, datasize=datasize, recerror=recerror, relchange=relchange) @@ -375,10 +374,3 @@ cellCellSimulate <- function(params = newCCSParams(), verbose = TRUE){ if(verbose){message("Done!")} list(input=input, LR=LR, celltypes=celltypes, LR_CCI=LR_CCI) } - -# -# convertToNCBIGeneID -# -convertToNCBIGeneID <- function(input, rowID, LefttoRight) { - .Deprecated(msg = "`scTensor::convertToNCBIGeneID` is deprecated; use `scTGIF::convertRowID` instead.") -} diff --git a/R/cellCellReport-Enrichment.R b/R/cellCellReport-Enrichment.R index 7d571e9..b4075fc 100644 --- a/R/cellCellReport-Enrichment.R +++ b/R/cellCellReport-Enrichment.R @@ -20,14 +20,15 @@ } } -.MeSHENRICHMENT <- function(all, sig, meshannotation, category, p){ - if(is.na(meshannotation)){ +.MeSHENRICHMENT <- function(all, sig, e, category, p){ + if(class(e$meshannotation) != "MeSHDb"){ list(Term=NULL, Pvalue=NULL) }else{ meshParams <- new("MeSHHyperGParams", geneIds = sig, universeGeneIds = all, - annotation = meshannotation, + annotation = "e$meshannotation", + meshdb = "e$meshdb", category = category, database = "gene2pubmed", pvalueCutoff = p, @@ -105,7 +106,9 @@ .NOSIG <- list(Term=NULL, PValue=NULL) -.ENRICHMENT <- function(all, sig, meshannotation, reactomespc, goenrich, meshenrich, reactomeenrich, doenrich, ncgenrich, dgnenrich, p, ah){ +.ENRICHMENT <- function(all, sig, e, + reactomespc, goenrich, meshenrich, reactomeenrich, + doenrich, ncgenrich, dgnenrich, p, ah){ # GO if(goenrich){ cat("GO-Enrichment Analysis is running...(1/3)\n") @@ -122,37 +125,37 @@ # MeSH if(meshenrich){ cat("MeSH-Enrichment Analysis is running...(1/16)\n") - A <- .MeSHENRICHMENT(all, sig, meshannotation, "A", p) + A <- .MeSHENRICHMENT(all, sig, e, "A", p) cat("MeSH-Enrichment Analysis is running...(2/16)\n") - B <- .MeSHENRICHMENT(all, sig, meshannotation, "B", p) + B <- .MeSHENRICHMENT(all, sig, e, "B", p) cat("MeSH-Enrichment Analysis is running...(3/16)\n") - C <- .MeSHENRICHMENT(all, sig, meshannotation, "C", p) + C <- .MeSHENRICHMENT(all, sig, e, "C", p) cat("MeSH-Enrichment Analysis is running...(4/16)\n") - D <- .MeSHENRICHMENT(all, sig, meshannotation, "D", p) + D <- .MeSHENRICHMENT(all, sig, e, "D", p) cat("MeSH-Enrichment Analysis is running...(5/16)\n") - E <- .MeSHENRICHMENT(all, sig, meshannotation, "E", p) + E <- .MeSHENRICHMENT(all, sig, e, "E", p) cat("MeSH-Enrichment Analysis is running...(6/16)\n") - F <- .MeSHENRICHMENT(all, sig, meshannotation, "F", p) + F <- .MeSHENRICHMENT(all, sig, e, "F", p) cat("MeSH-Enrichment Analysis is running...(7/16)\n") - G <- .MeSHENRICHMENT(all, sig, meshannotation, "G", p) + G <- .MeSHENRICHMENT(all, sig, e, "G", p) cat("MeSH-Enrichment Analysis is running...(8/16)\n") - H <- .MeSHENRICHMENT(all, sig, meshannotation, "H", p) + H <- .MeSHENRICHMENT(all, sig, e, "H", p) cat("MeSH-Enrichment Analysis is running...(9/16)\n") - I <- .MeSHENRICHMENT(all, sig, meshannotation, "I", p) + I <- .MeSHENRICHMENT(all, sig, e, "I", p) cat("MeSH-Enrichment Analysis is running...(10/16)\n") - J <- .MeSHENRICHMENT(all, sig, meshannotation, "J", p) + J <- .MeSHENRICHMENT(all, sig, e, "J", p) cat("MeSH-Enrichment Analysis is running...(11/16)\n") - K <- .MeSHENRICHMENT(all, sig, meshannotation, "K", p) + K <- .MeSHENRICHMENT(all, sig, e, "K", p) cat("MeSH-Enrichment Analysis is running...(12/16)\n") - L <- .MeSHENRICHMENT(all, sig, meshannotation, "L", p) + L <- .MeSHENRICHMENT(all, sig, e, "L", p) cat("MeSH-Enrichment Analysis is running...(13/16)\n") - M <- .MeSHENRICHMENT(all, sig, meshannotation, "M", p) + M <- .MeSHENRICHMENT(all, sig, e, "M", p) cat("MeSH-Enrichment Analysis is running...(14/16)\n") - N <- .MeSHENRICHMENT(all, sig, meshannotation, "N", p) + N <- .MeSHENRICHMENT(all, sig, e, "N", p) cat("MeSH-Enrichment Analysis is running...(15/16)\n") - V <- .MeSHENRICHMENT(all, sig, meshannotation, "V", p) + V <- .MeSHENRICHMENT(all, sig, e, "V", p) cat("MeSH-Enrichment Analysis is running...(16/16)\n") - Z <- .MeSHENRICHMENT(all, sig, meshannotation, "Z", p) + Z <- .MeSHENRICHMENT(all, sig, e, "Z", p) }else{ A <- .NOSIG B <- .NOSIG diff --git a/R/cellCellReport-NTD.R b/R/cellCellReport-NTD.R index 465696c..df71540 100644 --- a/R/cellCellReport-NTD.R +++ b/R/cellCellReport-NTD.R @@ -31,34 +31,13 @@ taxid <- dbGetQuery(con, "SELECT * FROM METADATA") taxid <- taxid[which(taxid$NAME == "TAXID"), "VALUE"] dbDisconnect(con) - if(length(taxid) == 0){ - ########################################### - # Threename based information retrieval - ########################################### - message(paste("Old LRBase is being used.", - "Please update it to the newer version 2.0.")) - # Species - spc <- gsub(".eg.db.sqlite", "", - strsplit(metadata(sce)$lrbase, "LRBase.")[[1]][3]) - taxid <- as.character(.TAXID[spc]) - # biomaRt Setting - ah <- .annotationhub[[spc]]() - # GeneName, Description, GO, Reactome, MeSH - GeneInfo <- .geneInformation(sce, ah, spc, LR) - # The version of LRBase.XXX.eg.db - lrversion <- 1 - }else{ - ########################################### - # Taxonomy ID based information retrieval - ########################################### - # biomaRt Setting - ah <- .annotationhub_taxid(taxid) - # GeneName, Description, GO, Reactome, MeSH - GeneInfo <- .geneInformation_taxid(sce, ah, taxid, LR) - # The version of LRBase.XXX.eg.db - lrversion <- 2 - } - + ########################################### + # Taxonomy ID based information retrieval + ########################################### + # biomaRt Setting + ah <- .annotationhub_taxid(taxid) + # GeneName, Description, GO, Reactome, MeSH + GeneInfo <- .geneInformation_taxid(sce, ah, taxid, LR) # Cell Label celltypes <- metadata(sce)$color names(celltypes) <- metadata(sce)$label @@ -116,7 +95,6 @@ e$doenrich <- doenrich e$ncgenrich <- ncgenrich e$dgnenrich <- dgnenrich - e$lrversion <- lrversion # EachVec(Heavy...) out.vecLR <- vapply(SelectedLR, diff --git a/R/cellCellReport-NTD2.R b/R/cellCellReport-NTD2.R index 932a379..69141c9 100644 --- a/R/cellCellReport-NTD2.R +++ b/R/cellCellReport-NTD2.R @@ -31,45 +31,22 @@ taxid <- dbGetQuery(con, "SELECT * FROM METADATA") taxid <- taxid[which(taxid$NAME == "TAXID"), "VALUE"] dbDisconnect(con) - if(length(taxid) == 0){ - ########################################### - # Threename based information retrieval - ########################################### - message(paste("Old LRBase is being used.", - "Please consider updating it to the newer version 2.0.")) - # Species - spc <- gsub(".eg.db.sqlite", "", - strsplit(metadata(sce)$lrbase, "LRBase.")[[1]][3]) - taxid <- as.character(.TAXID[spc]) - # biomaRt Setting - ah <- .annotationhub[[spc]]() - # GeneName, Description, GO, Reactome, MeSH - GeneInfo <- .geneInformation(sce, ah, spc, LR) - # The version of LRBase.XXX.eg.db - lrversion <- 1 - }else{ - ########################################### - # Taxonomy ID based information retrieval - ########################################### - # biomaRt Setting - ah <- .annotationhub_taxid(taxid) - # GeneName, Description, GO, Reactome, MeSH - GeneInfo <- .geneInformation_taxid(sce, ah, taxid, LR) - # The version of LRBase.XXX.eg.db - lrversion <- 2 - } - + ########################################### + # Taxonomy ID based information retrieval + ########################################### + # biomaRt Setting + ah <- .annotationhub_taxid(taxid) + # GeneName, Description, GO, Reactome, MeSH + GeneInfo <- .geneInformation_taxid(sce, ah, taxid, LR) # Cell Label celltypes <- metadata(sce)$color names(celltypes) <- metadata(sce)$label - # Setting of schex sce <- make_hexbin(sce, nbins=nbins, dimension_reduction=reducedDimNames) # Plot Ligand/Receptor Genes suppressMessages( invisible(.genePlot(sce, assayNames, input, out.dir, GeneInfo, LR))) - # Plot (Each ) out <- vapply(seq_along(selected), function(i){ filenames <- paste0(out.dir, @@ -84,7 +61,6 @@ }, 0L) # SelectedLR <- index[selected, seq_len(2)] - # Setting for Parallel Computing message(paste0(length(selected), " LR vectors will be calculated :")) @@ -117,7 +93,6 @@ e$doenrich <- doenrich e$ncgenrich <- ncgenrich e$dgnenrich <- dgnenrich - e$lrversion <- lrversion # EachVec(Heavy...) if(is.vector(SelectedLR)){ diff --git a/R/cellCellReport-internal.R b/R/cellCellReport-internal.R index 5e34c61..611dce3 100644 --- a/R/cellCellReport-internal.R +++ b/R/cellCellReport-internal.R @@ -53,23 +53,22 @@ .palf <- colorRampPalette(c("#4b61ba", "gray", "#a87963", "red")) -.REACTOMESPC <- list( - "Aga" = "anopheles", - "Ath" = "arabidopsis", - "Bta" = "bovine", - "Cfa" = "canine", - "Cel" = "celegans", - "Gga" = "chicken", - "Ptr" = "chimp", - "Dme" = "fly", - "Tgo" = "gondii", - "Hsa" = "human", - "Pfa" = "malaria", - "Mmu" = "mouse", - "Ssc" = "pig", - "Rno" = "rat", - "Xla" = "xenopus", - "Dre" = "zebrafish" +.REACTOMESPC_taxid <- list( + "7165" = "anopheles", + "3702" = "arabidopsis", + "9913" = "bovine", + "9615" = "canine", + "6239" = "celegans", + "9031" = "chicken", + "9598" = "chimp", + "7227" = "fly", + "5811" = "gondii", + "9606" = "human", + "10090" = "mouse", + "9823" = "pig", + "10116" = "rat", + "8355" = "xenopus", + "7955" = "zebrafish" ) .ggdefault_cols <- function(n){ @@ -209,8 +208,9 @@ } .smallTwoDplot <- function(sce, assayNames, geneid, genename, color){ - g <- schex::plot_hexbin_gene(sce, type=assayNames, gene=geneid, - action="mean", xlab="Dim1", ylab="Dim2", + g <- schex::plot_hexbin_feature(sce, type=assayNames, + feature=geneid, action="mean", + xlab="Dim1", ylab="Dim2", title=paste0("Mean of ", genename)) if(color == "reds"){ g <- g + scale_fill_gradient(low = 'gray', high = 'red') @@ -221,7 +221,6 @@ g } - # For previous LRBase (v-1.0.0 - v-1.2.0) .TAXID <- c( "Hsa" = 9606, @@ -838,7 +837,6 @@ doenrich <- e$doenrich ncgenrich <- e$ncgenrich dgnenrich <- e$dgnenrich - lrversion <- e$lrversion # Each LR-Pattern Vector if(algorithm == "ntd2"){ @@ -864,47 +862,46 @@ TOP <- "full" } # L-R evidence - if(lrversion != 1){ - targetL <- unlist(lapply(names(TARGET), function(x){strsplit(x, "_")[[1]][1]})) - targetR <- unlist(lapply(names(TARGET), function(x){strsplit(x, "_")[[1]][2]})) - targetL <- unlist(lapply(targetL, function(x){ - which(LR$GENEID_L == x) - })) - targetR <- unlist(lapply(targetR, function(x){ - which(LR$GENEID_R == x) - })) - target <- intersect(targetL, targetR) - Evidence <- LR[target, "SOURCEDB"] - }else{ - Evidence <- rep("", length=length(TARGET)) - } + targetL <- unlist(lapply(names(TARGET), function(x){strsplit(x, "_")[[1]][1]})) + targetR <- unlist(lapply(names(TARGET), function(x){strsplit(x, "_")[[1]][2]})) + targetL <- unlist(lapply(targetL, function(x){ + which(LR$GENEID_L == x) + })) + targetR <- unlist(lapply(targetR, function(x){ + which(LR$GENEID_R == x) + })) + target <- intersect(targetL, targetR) + Evidence <- LR[target, "SOURCEDB"] # Enrichment (Too Heavy) all <- unique(unlist(strsplit(names(vecLR), "_"))) sig <- unique(unlist(strsplit(names(TARGET), "_"))) - spc <- gsub(".eg.db.sqlite", "", - strsplit(metadata(sce)$lrbase, "LRBase.")[[1]][3]) # GO-Check if("GO" %ni% AnnotationDbi::columns(ah)){ goenrich <- FALSE } # MeSH-Check - MeSHname <- paste0("MeSH.", spc, ".eg.db") - MeSH.load <- eval(parse(text=paste0("try(requireNamespace('", MeSHname, "', quietly=TRUE), silent=TRUE)"))) - if(!MeSH.load){ - eval(parse(text=paste0("try(BiocManager::install('", - MeSHname, "', update=FALSE, ask=FALSE), silent=TRUE)"))) - } - MeSH.load2 <- eval(parse(text=paste0("try(require('", MeSHname, "', quietly=TRUE), silent=TRUE)"))) - if(MeSH.load2){ - eval(parse(text=paste0("library(", MeSHname, ")"))) - meshannotation <- MeSHname + ah <- AnnotationHub() + mcah <- mcols(ah) + mesh_org_msg <- gsub("LRBaseDb", "MeSHDb", + ah[metadata(sce)$ahid]$title) + position <- regexpr("v[0-9][0-9][0-9]", mesh_org_msg) + mesh_version <- substr(mesh_org_msg, position, position + 3) + mesh_db_msg <- paste0("MeSHDb for MeSH.db (", mesh_version, ")") + ahid1 <- mcah@rownames[which(mcah@listData$title == mesh_org_msg)] + ahid2 <- mcah@rownames[which(mcah@listData$title == mesh_db_msg)] + if(length(ahid1) != 0){ + message(paste0("Related MeSH IDs are retrieved from ", + "AnnotationHub...")) + e$meshannotation <- MeSHDbi::MeSHDb(ah[[ahid1]]) + e$meshdb <- MeSHDbi::MeSHDb(ah[[ahid2]]) }else{ meshenrich <- FALSE - meshannotation <- NA + e$meshannotation <- NA + e$meshdb <- NA } # Reactome-Check - reactomespc <- .REACTOMESPC[[spc]] + reactomespc <- .REACTOMESPC_taxid[[taxid]] if(is.null(reactomespc)){ reactomeenrich <- FALSE } @@ -915,8 +912,8 @@ dgnenrich <- FALSE } Enrich <- suppressWarnings(.ENRICHMENT(all, sig, - meshannotation, reactomespc, - goenrich, meshenrich, reactomeenrich, doenrich, ncgenrich, dgnenrich, p, ah)) + e, reactomespc, goenrich, meshenrich, + reactomeenrich, doenrich, ncgenrich, dgnenrich, p, ah)) # Eigen Value # Each LR-Pattern Vector diff --git a/R/geneInformation.R b/R/geneInformation.R index 3faba2a..a13416e 100644 --- a/R/geneInformation.R +++ b/R/geneInformation.R @@ -1,6 +1,5 @@ .geneInformation_taxid <- function(sce, ah, taxid, LR){ targetGeneID <- as.character(unique(c(LR$GENEID_L, LR$GENEID_R))) - # Gene symbol if("SYMBOL" %in% AnnotationDbi::columns(ah) && !is.null(ah)){ message("Related gene names are retrieved from AnnotationHub...") @@ -80,19 +79,15 @@ } # MeSH - MeSHname <- paste0("MeSH.", gsub(".eg.db.sqlite", "", - strsplit(metadata(sce)$lrbase, "LRBase.")[[1]][3]), ".eg.db") - MeSH.load <- eval(parse(text=paste0("try(requireNamespace('", MeSHname, "', quietly=TRUE), silent=TRUE)"))) - if(!MeSH.load){ - eval(parse(text=paste0("try(BiocManager::install('", - MeSHname, "', update=FALSE, ask=FALSE), silent=TRUE)"))) - } - MeSH.load2 <- eval(parse(text=paste0("try(require('", MeSHname, "', quietly=TRUE), silent=TRUE)"))) - if(MeSH.load2){ - eval(parse(text=paste0("library(", MeSHname, ")"))) + ah <- AnnotationHub() + mcah <- mcols(ah) + msg <- gsub("LRBaseDb", "MeSHDb", ah[metadata(sce)$ahid]$title) + ahid <- mcah@rownames[which(mcah@listData$title == msg)] + if(length(ahid) != 0){ message(paste0("Related MeSH IDs are retrieved from ", - "MeSH.XXX.eg.db-type package...")) - MeSHobj <- eval(parse(text=MeSHname)) + "AnnotationHub...")) + MeSHfile <- ah[[ahid]] + MeSHobj <- MeSHDbi::MeSHDb(MeSHfile) MeSH <- MeSHDbi::select(MeSHobj, columns=c("MESHID", "GENEID"), keytype="GENEID", keys=targetGeneID) diff --git a/README.md b/README.md index 43b0ed2..540b328 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # scTensor R package for detection of cell-cell interaction using Non-negative Tensor Decomposition - Installation of Dependent Packages ====== ```r diff --git a/inst/NEWS b/inst/NEWS index e215055..3587eb3 100644 --- a/inst/NEWS +++ b/inst/NEWS @@ -1,7 +1,14 @@ +VERSION 2.4.1 +------------------------ + o A vignette modified. + VERSION 2.4.0 ------------------------ o Regularizer parameter (L2_A/L1_A) was added in cellCellDecomp() ("ntd", "ntd2"). o Multilinear CX Decompotision was added in cellCellDecomp() ("cx"). + o convertNCBIGeneID is removed. + o The vignettes were modified. + o Support of LRBase.XXX.eg.db-type packages is completely deprecated VERSION 2.0.0 ------------------------ diff --git a/man/cellCellReport.Rd b/man/cellCellReport.Rd index bd1c068..88a487a 100644 --- a/man/cellCellReport.Rd +++ b/man/cellCellReport.Rd @@ -98,7 +98,7 @@ The result is saved as HTML report which contains with multiple files. library(LRBaseDbi) } ah <- AnnotationHub() - dbfile <- query(ah, c("LRBaseDb", "Homo sapiens", "v001"))[[1]] + dbfile <- query(ah, c("LRBaseDb", "Homo sapiens", "v002"))[[1]] LRBase.Hsa.eg.db <- LRBaseDbi::LRBaseDb(dbfile) # Data Loading diff --git a/man/convertToNCBIGeneID.Rd b/man/convertToNCBIGeneID.Rd deleted file mode 100644 index 7c066b9..0000000 --- a/man/convertToNCBIGeneID.Rd +++ /dev/null @@ -1,47 +0,0 @@ -\name{convertToNCBIGeneID} -\docType{methods} -\alias{convertToNCBIGeneID} - -\title{ -ID conversion function to create the input matrix for scTensor -} -\description{ -Duplicated row names or NA row names are removed from input matrix, -and the matrix with the row names of NCBI Gene ID is generated. -} -\usage{ -convertToNCBIGeneID(input, rowID, LefttoRight) -} - -\arguments{ -\item{input}{ -Input matrix (or data.frame). -} -\item{rowID}{ -Gene identifier in each row of the input matrix. -The length of rowID must be same as the number of tht input matrix. -} -\item{LefttoRight}{ -Corresponding table with left column (Gene identifier ) and right column (NCBI Gene ID). -} -} - -\value{ -A matrix object with with the row names of NCBI Gene ID. -} - -\author{Koki Tsuyuzaki} - -\examples{ -input <- matrix(1:20, nrow=4, ncol=5) -rowID <- c("A", NA, "B", "B") -LefttoRight <- rbind( - c("A", "1"), - c("B", "2"), - c("B", "4"), - c("D", NA) -) -(input <- convertToNCBIGeneID(input, rowID, LefttoRight)) -} - -\keyword{methods} \ No newline at end of file diff --git a/vignettes/scTensor.Rmd b/vignettes/scTensor.Rmd index 6c0c8ab..7bb9e25 100644 --- a/vignettes/scTensor.Rmd +++ b/vignettes/scTensor.Rmd @@ -27,7 +27,7 @@ This section is for the users of previous LRBase.XXX.eg.db-type packages and scT - The installation time of the entire Bioconductor packages will be reduced. - Old data will be archived. -- Data reproducibility is ensured (e.g. the version of the data can be specified, such as "v001"). +- Data reproducibility is ensured (e.g. the version of the data can be specified, such as "v002"). # Introduction ## About Cell-Cell Interaction (CCI) databases @@ -64,7 +64,7 @@ Please see the evidence code of lrbase-workflow^[https://github.com/rikenbit/lrb First of all, we download the data of LRBase from AnnotationHub. `AnnotationHub::AnnotationHub` retrieve the metadata of all the data stored in cloud server. -```{r AHub1, echo=FALSE} +```{r AHub1, echo=TRUE} library("AnnotationHub") ah <- AnnotationHub() mcols(ah) @@ -72,15 +72,15 @@ mcols(ah) Specifying some keywords in `query()`, we can find LRBase data in AnnotationHub. -```{r AHub2, echo=FALSE} -dbfile <- query(ah, c("LRBaseDb", "Homo sapiens", "v001"))[[1]] +```{r AHub2, echo=TRUE} +dbfile <- query(ah, c("LRBaseDb", "Homo sapiens", "v002"))[[1]] ``` AnnotationHub also keeps old data as an archive, so please make sure you have the latest version (e.g. "v002" or higher) when you search for LRBaseDb. Then, we can convert `dbfile` into LRBase object by using `LRBaseDbi`. -```{r AHub3, echo=FALSE} +```{r AHub3, echo=TRUE} library("LRBaseDbi") LRBase.Hsa.eg.db <- LRBaseDbi::LRBaseDb(dbfile) ``` @@ -143,7 +143,7 @@ We assume that user has a scRNA-Seq data matrix containing expression count data To improve the interpretability of the following HTML report, we highly recommend that user specifies the two-dimensional data of input data (e.g. PCA, t-SNE, or UMAP). Such information is easily specified by `reducedDims` function of `r Biocpkg("SingleCellExperiment")` package and is saved to reducedDims slot of `SingleCellExperiment` object (Figure \@ref(fig:cellCellSetting)). -```{r SCE1, echo=FALSE} +```{r SCE1, echo=TRUE} suppressPackageStartupMessages(library("scTensor")) suppressPackageStartupMessages(library("SingleCellExperiment")) ``` diff --git a/vignettes/scTensor_1_Data_format_ID_Conversion.Rmd b/vignettes/scTensor_1_Data_format_ID_Conversion.Rmd index 040c241..d5c1b51 100644 --- a/vignettes/scTensor_1_Data_format_ID_Conversion.Rmd +++ b/vignettes/scTensor_1_Data_format_ID_Conversion.Rmd @@ -38,7 +38,7 @@ sce <- SingleCellExperiment(assays=list(counts = input)) label <- ... # LRBase.XXX.eg.db ah <- AnnotationHub() -dbfile <- query(ah, c("LRBaseDb", "Homo sapiens", "v001"))[[1]] +dbfile <- query(ah, c("LRBaseDb", "Homo sapiens", "v002"))[[1]] LRBase.Hsa.eg.db <- LRBaseDbi::LRBaseDb(dbfile) # Setting cellCellSetting(sce, LRBase.Hsa.eg.db, label) diff --git a/vignettes/scTensor_4_Reanalysis.Rmd b/vignettes/scTensor_4_Reanalysis.Rmd index e6e4364..5e7c354 100644 --- a/vignettes/scTensor_4_Reanalysis.Rmd +++ b/vignettes/scTensor_4_Reanalysis.Rmd @@ -25,7 +25,7 @@ vignette: | Here, we introduced the objects saved in reanalysis.RData. ```{r reanalysis.RData, eval=FALSE} -suppressPackageStartupMessages(library("scTensor")) +library("scTensor") load("reanalysis.RData") ``` @@ -65,14 +65,20 @@ For example, some users want to perform `cellCellDecomp` with different ranks, p To do such tasks, just type like belows. ```{r Reanalysis, eval=FALSE} -if(!require(LRBase.Hsa.eg.db)){ - BiocManager::install("LRBase.Hsa.eg.db") - suppressPackageStartupMessages(library(LRBase.Hsa.eg.db)) -} +library("AnnotationHub") +library("LRBaseDbi") + +# Create LRBase object +ah <- AnnotationHub() +dbfile <- query(ah, c("LRBaseDb", "Homo sapiens", "v002"))[[1]] +LRBase.Hsa.eg.db <- LRBaseDbi::LRBaseDb(dbfile) + # Register the file pass of user's LRBase metadata(sce)$lrbase <- dbfile(LRBase.Hsa.eg.db) + # CCI Tensor Decomposition cellCellDecomp(sce, ranks=c(6,5), assayNames="normcounts") + # HTML Report cellCellReport(sce, reducedDimNames="TSNE", assayNames="normcounts", title="Cell-cell interaction within Germline_Male, GSE86146",