Skip to content

Commit

Permalink
bugfix previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dimalvovs committed May 21, 2024
1 parent efb36e7 commit 37c8297
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions modules/local/spacemarkers.nf
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,26 @@ process SPACEMARKERS {
"""
mkdir "${prefix}"
Rscript -e 'library("SpaceMarkers");
#load spatial coordinates from tissue positions
coords <- load10XCoords("$data");
features <- getSpatialFeatures("$cogapsResult");
spPatterns <- merge(coords, features, by.x = "barcode", by.y = "row.names");
#load spatial coords from tissue positions, deconvolved patterns, and expression
coords <- load10XCoords("$data")
features <- getSpatialFeatures("$cogapsResult")
dataMatrix <- load10XExpr("$data")
#add spatial coordinates to deconvolved data, only use barcodes present in data
spPatterns <- merge(coords, features, by.x = "barcode", by.y = "row.names")
spPatterns <- spPatterns[which(spPatterns[,"barcode"] %in% colnames(dataMatrix)),]
saveRDS(spPatterns, file = "${prefix}/spPatterns.rds");
#load expression data, rm low expression genes, rm barcodes w/o spatial
dataMatrix <- load10XExpr("$data");
keepGenes <- which(apply(dataMatrix, 1, sum) > 10);
keepBarcodes <- which(colnames(dataMatrix) %in% spPatterns["barcode"]);
dataMatrix <- dataMatrix[keepGenes, keepBarcodes];
#remove genes with low expression, only barcodes present in spatial data
keepGenes <- which(apply(dataMatrix, 1, sum) > 10)
keepBarcodes <- which(colnames(dataMatrix) %in% spPatterns[,"barcode"])
dataMatrix <- dataMatrix[keepGenes, keepBarcodes]
#compute optimal parameters for spatial patterns
optParams <- getSpatialParameters(spPatterns);
saveRDS(optParams, file = "${prefix}/optParams.rds");
#find genes that are differentially expressed in spatial patterns
spaceMarkers <- getInteractingGenes(data = dataMatrix, \
optParams = optParams, \
spPatterns = spPatterns, \
Expand Down

0 comments on commit 37c8297

Please sign in to comment.