Skip to content

Commit

Permalink
v-2.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kokitsuyuzaki committed Dec 16, 2021
1 parent 52caad8 commit 1b424b9
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 225 deletions.
12 changes: 6 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"),
person("Kozo", "Nishida", role = "aut",
Expand All @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
export(cellCellSimulate, newCCSParams)
14 changes: 3 additions & 11 deletions R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand All @@ -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])
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.")
}
43 changes: 23 additions & 20 deletions R/cellCellReport-Enrichment.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand Down
36 changes: 7 additions & 29 deletions R/cellCellReport-NTD.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -116,7 +95,6 @@
e$doenrich <- doenrich
e$ncgenrich <- ncgenrich
e$dgnenrich <- dgnenrich
e$lrversion <- lrversion

# EachVec(Heavy...)
out.vecLR <- vapply(SelectedLR,
Expand Down
39 changes: 7 additions & 32 deletions R/cellCellReport-NTD2.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 <L,R,*>)
out <- vapply(seq_along(selected), function(i){
filenames <- paste0(out.dir,
Expand All @@ -84,7 +61,6 @@
}, 0L)
# <L,R,>
SelectedLR <- index[selected, seq_len(2)]

# Setting for Parallel Computing
message(paste0(length(selected),
" LR vectors will be calculated :"))
Expand Down Expand Up @@ -117,7 +93,6 @@
e$doenrich <- doenrich
e$ncgenrich <- ncgenrich
e$dgnenrich <- dgnenrich
e$lrversion <- lrversion

# EachVec(Heavy...)
if(is.vector(SelectedLR)){
Expand Down
Loading

0 comments on commit 1b424b9

Please sign in to comment.