Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pairwise #15

Merged
merged 10 commits into from
Aug 12, 2024
10 changes: 6 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Type: Package
Package: SpaceMarkers
Title: Spatial Interaction Markers
Version: 1.11.1
Version: 1.1.2
Authors@R: c(
person(given = "Atul", family = "Deshpande", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID="0000-0001-5144-6924")),
person(given = "Ludmila", family = "Danilova", email = "[email protected]", role = "ctb"),
person(given = "Dimitrijs", family = "Lvovs", email = "[email protected]", role = "ctb")
person(given = "Dmitrijs", family = "Lvovs", email = "[email protected]", role = "ctb", comment = c(ORCID = "0009-0003-2152-6853"))
)
BugReports: https://github.com/atuldeshpande/SpaceMarkers/issues
URL: https://github.com/atuldeshpande/SpaceMarkers
BugReports: https://github.com/DeshpandeLab/SpaceMarkers/issues
URL: https://github.com/DeshpandeLab/SpaceMarkers
Description: Spatial transcriptomic technologies have helped to resolve the connection
between gene expression and the 2D orientation of tissues relative to each other.
However, the limited single-cell resolution makes it difficult to highlight the most
Expand Down Expand Up @@ -48,6 +48,8 @@ Suggests:
testthat (>= 3.0.0),
viridis,
CoGAPS
Enhances:
BiocParallel
VignetteBuilder:
knitr
Config/testthat/edition: 3
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(getInteractingGenes)
export(getPairwiseInteractingGenes)
export(getSpatialFeatures)
export(getSpatialParameters)
export(load10XCoords)
Expand Down
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# SpaceMarkers development version
# SpaceMarkers 1.1.2

* Added getPairwiseInteractingGenes which enables pairwise analysis of
interacting patterns

# SpaceMarkers 1.1.1

* `getSpatialFeatures`: add default method to infer the object passed to it.

Expand Down
31 changes: 18 additions & 13 deletions R/find_genes_of_interest.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,15 @@ return(cbind(zVals,pvals))
#===================
#' find_genes_of_interest
#' Identify genes associated with pattern interaction.

#' This function identifies genes exhibiting significantly higher values of
#' testMat in the Interaction region of the two
#' patterns compared #' to regions with exclusive influence from either
#' patterns compared to regions with exclusive influence from either
#' pattern. It uses Kruskal-Wallis test followed by
#' posthoc analysis using Dunn's Test to identify the genes.
#'
#' @usage
#' find_genes_of_interest(
#' testMat,
#' goodGenes = NULL,
#' region,
#' fdr.level = 0.05,
#' analysis = c("enrichment", "overlap")
#' )
#' find_genes_of_interest(testMat, goodGenes, region, fdr.level=0.05,
#' analysis=c("enrichment","overlap"),...)
#' @param testMat A matrix of counts with cells as columns and genes as rows
#' @param goodGenes A vector of user specified genes expected to interact
#' a priori. The default for this is NULL as the function can find these genes
Expand All @@ -72,18 +66,23 @@ return(cbind(zVals,pvals))
#' @param fdr.level False Discovery Rate. The default value is 0.05.
#' @param analysis a character string that specifies the type of analysis to
#' carry out, whether overlap or enrichment.
#'
#' @param ... Additional arguments to be passed to lower level functions
#' @return a list of genes exhibiting significantly higher values of testMat in
#' the Interaction region of the two #' patterns compared to regions with
#' exclusive influence from either pattern.



find_genes_of_interest<-function(
dimalvovs marked this conversation as resolved.
Show resolved Hide resolved
testMat,goodGenes=NULL,region, fdr.level=0.05,
analysis=c("enrichment","overlap")) {
analysis=c("enrichment","overlap"),...) {

# Default analysis = enrichment
if ("enrichment" %in% analysis) {analysis <- "enrichment"}
else if ("overlap" %in% analysis) {analysis <- "overlap"}
else stop("analysis must be either 'enrichment' or 'overlap'")

region <- factor(region)
patnames <- levels(region)[which(levels(region)!="Interacting")]

pattern1 <- patnames[1]
pattern2 <- patnames[2]
if (!is.null(goodGenes)){
Expand All @@ -104,6 +103,12 @@ find_genes_of_interest<-function(
qDunn$qvalues[ind,] <- qq$qvalue
res_dunn_test <- cbind(res_dunn_test,qDunn$qvalues)
colnames(res_dunn_test)[7:9] <- paste0(colnames(res_dunn_test)[7:9],".adj")
interactGenes <- buildInteractGenesdf(res_kruskal,
res_dunn_test,ind,fdr.level, pattern1,pattern2,analysis)
return(interactGenes)
}
buildInteractGenesdf <- function(res_kruskal,res_dunn_test,ind,
fdr.level=0.05,pattern1,pattern2,analysis) {
interact_patt1 <- res_dunn_test[ind,"pval_1_Int.adj"]<fdr.level
interact_patt2 <- res_dunn_test[ind,"pval_2_Int.adj"]<fdr.level
interacting_over_both_patterns <- interact_patt1 & interact_patt2
Expand Down
Loading
Loading