Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: SpaceTrooper
Type: Package
Title: SpaceTrooper performs Quality Control analysis of Image-Based spatial
Version: 1.1.7
Version: 1.1.8

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BenedettaBanzi never do the version bump together with all the modifications.
It requires a different commit.

Authors@R:
c(person("Dario", "Righelli",
email="dario.righelli@gmail.com",
Expand Down
8 changes: 4 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Generated by roxygen2: do not edit by hand

export(.applyQScoreModel)
export(.getActiveGeometryName)
export(.renameGeometry)
export(.setActiveGeometry)
export(addPolygonsToSPE)
export(applyQCScoreModel)
export(checkOutliers)
export(computeAreaFromPolygons)
export(computeAspectRatioFromPolygons)
export(computeCenterFromPolygons)
export(computeLambda)
export(computeMissingMetricsMerfish)
export(computeMissingMetricsXenium)
export(computeOutliersQCScore)
export(computeQCScore)
export(computeQCScoreFlags)
export(computeOutliersQScore)
export(computeQScore)
export(computeQScoreFlags)
export(computeSpatialOutlier)
export(computeThresholdFlags)
export(computeTrainDF)
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changes in version 1.1.8

* fixing naming of of spacetrooper utilities vignette
* adding functions for QC model transfer across datasets
* implementing Quality Score computation with custom formula
* fixing naming of spacetrooper utilities vignette
* adding citation file with biorxiv paper

# Changes in version 1.1.7
Expand Down
529 changes: 268 additions & 261 deletions R/QC.R

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion R/readMerfish.R
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ computeMissingMetricsMerfish <- function(polFile, coldata,
warning("Volume column not found in colData.\nComputing area from polygons instead.")
area <- computeAreaFromPolygons(polygons)
} else {
warning("Volume is used to compute QC score for MERFISH technology.
warning("Volume is used to compute Quality Score for MERFISH technology.
For simplicity, it is renamed as Area_um.")
area <- cd$volume
}
Expand Down
45 changes: 24 additions & 21 deletions R/spatialQCPlots.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
#' @param sampleId Character string identifying which sample to plot.
#' Default: `unique(spe$sample_id)`.
#' @param pointCol Color for the cell centroids. Default: `"firebrick"`.
#' @param pointSize Numeric point size for the cell centroids. Default: `0.05`.
#' @param pointAlpha Numeric transparency for the cell centroids. Default: `0.8`.
#' @param numbersCol Color for the FoV labels. Default: `"black"`.
#' @param alphaNumbers Numeric transparency for FoV labels. Default: `0.8`.
#' @param numberSize Numeric size for the FoV labels. Default: `1`.
#' @param numbersAlpha Numeric transparency for FoV labels. Default: `0.8`.
#' @param fovDim numeric with two named dimensions xdim, ydim. (Default is
#' metadata(spe)$fov_dim)
#' @param size Numeric point size for the cell centroids. Default: `0.05`.
#' @param alpha Numeric transparency for the cell centroids. Default: `0.8`.
#' @param scaleBar A logical value indicating whether to add a scale bar to the
#' plot. (Default is `TRUE`)
#' @param micronConvFact Numeric conversion factor from pixels to microns.
Expand All @@ -29,7 +30,7 @@
#' - `metadata(spe)$fov_positions`: a matrix or data.frame
#' (or list with named elements) containing at minimum `x_global_px`, `y_global_px`,
#' and `fov`. Values `x_global_px`/`y_global_px` are in pixels and represent
#' the origin (top-left) of each FoV.
#' the origin (bottom-left) of each FoV.
#' - `metadata(spe)$fov_dim` (or the `fovDim` argument): a named numeric with
#' `xdim` and `ydim` giving FoV width/height in pixels.
#'
Expand Down Expand Up @@ -61,9 +62,10 @@
#' g <- plotCellsFovs(spe)
#' print(g)
plotCellsFovs <- function(spe, sampleId=unique(spe$sample_id),
pointCol="firebrick", numbersCol="black",
alphaNumbers=0.8, fovDim=metadata(spe)$fov_dim,
size=0.05, alpha=0.8,
pointCol="firebrick", pointSize=0.05,
pointAlpha=0.8, numbersCol="black",
numberSize= 1, numbersAlpha=0.8,
fovDim=metadata(spe)$fov_dim,
Comment on lines 64 to +68

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scaleBar=TRUE, micronConvFact = 0.12)
{
stopifnot(is(spe, "SpatialExperiment"))
Expand All @@ -78,7 +80,7 @@ plotCellsFovs <- function(spe, sampleId=unique(spe$sample_id),
y=.data[[y_coord]]),
colour=pointCol,
fill=pointCol,
size=size, alpha=alpha) +
size=pointSize, alpha=pointAlpha) +
annotate("rect",
xmin=metadata(spe)$fov_positions["x_global_px"][ , , drop=TRUE],
xmax=metadata(spe)$fov_positions["x_global_px"][ , , drop=TRUE] +
Expand All @@ -92,7 +94,8 @@ plotCellsFovs <- function(spe, sampleId=unique(spe$sample_id),
y=metadata(spe)$fov_positions["y_global_px"][,,drop=TRUE]+
fovDim[["ydim"]]/2,
label=metadata(spe)$fov_positions["fov"][,,drop=TRUE]),
color=numbersCol, fontface="bold", alpha=alphaNumbers) +
color=numbersCol, size = numberSize, alpha=numbersAlpha,
fontface="bold") +
ggtitle(sampleId) +
.fov_image_theme(backColor="white", backBorder="white",
titleCol="black") + ggplot2::coord_fixed()
Expand Down Expand Up @@ -436,14 +439,12 @@ plotPolygons <- function(spe, colourBy="darkgrey", colourLog=FALSE,
#' plot. If `NULL`, no title is added. Default is `NULL`.
#' @param mapPointCol A character string specifying the color of the points
#' in the map. Default is `"darkmagenta"`.
#' @param mapNumbersCol A character string specifying the color of the
#' numbers on the map. Default is `"black"`.
#' @param mapAlphaNumbers A numeric value specifying the transparency of the
#' numbers on the map. Default is `0.8`.
#' @param csize A numeric value specifying the size of the points in the map.
#' Default is `0.05`.
#' @param calpha A numeric value specifying the transparency of the points in
#' the map. Default is `0.8`.
#' @param mapPointSize Numeric size for points in the map. Default: `0.5`.
#' @param mapPointAlpha Numeric transparency for points in the map. Default: `0.8`.
#' @param fovNumbersCol A character string specifying the color of the
#' numbers on the FoV zoom-in. Default is `"black"`.
#' @param fovNumberSize Numeric size for the FoV labels. Default: `1`.
#' @param fovNumbersAlpha Numeric transparency for FoV labels. Default: `0.8`.
#' @param scaleBars Logical or NULL. Default is `NULL`.
#' Master switch controlling the presence of scale bars in both panels.
#' If \code{TRUE}, scale bars are shown in both the map and polygon panels.
Expand Down Expand Up @@ -474,8 +475,9 @@ plotPolygons <- function(spe, colourBy="darkgrey", colourLog=FALSE,
#' plotZoomFovsMap(spe, fovs=16, title="FOV 16")
plotZoomFovsMap <- function(spe, fovs=NULL, title=NULL,
mapPointCol="darkmagenta",
mapNumbersCol="black",
mapAlphaNumbers=0.8,
mapPointSize=0.5, mapPointAlpha=0.8,
fovNumbersCol="black", fovNumberSize=1,
fovNumbersAlpha=0.8,
csize=0.05, calpha=0.8,
scaleBars=NULL,
scaleBarMap=TRUE,
Expand All @@ -491,8 +493,9 @@ plotZoomFovsMap <- function(spe, fovs=NULL, title=NULL,
scaleBarPol <- scaleBars
}
map <- plotCellsFovs(spefovs, pointCol=mapPointCol,
numbersCol=mapNumbersCol, alphaNumbers=mapAlphaNumbers,
sampleId=NULL, size=csize, alpha=calpha, scaleBar=scaleBarMap)
pointSize=mapPointSize, pointAlpha=mapPointAlpha,
numbersCol=fovNumbersCol, numberSize=fovNumberSize,
numbersAlpha=fovNumbersAlpha, sampleId=NULL, scaleBar=scaleBarMap)
Comment on lines 495 to +498

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g2 <- plotPolygons(spefovs, sampleId=NULL, scaleBar=scaleBarPol, ...)
final_plot <- ggpubr::ggarrange(map, g2, ncol=2)
if (!is.null(title)) {
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ spe <- readAndAddPolygonsToSPE(spe, boundariesType="csv")
spe <- spatialPerCellQC(spe)

# 4. Compute QS and, optionally, flag cells with a score higher than 'qsThreshold'.
spe <- computeQCScore(spe)
spe <- computeQCScoreFlags(spe, qsThreshold=0.5)
spe <- computeQScore(spe)
spe <- computeQScoreFlags(spe, qsThreshold=0.5)

# 5. Visualization
## Visualize cells as dots in their centroid coordinates, colored by a column in `colData(spe)` (e.g., QS computed above).
Expand Down
61 changes: 0 additions & 61 deletions man/applyQCScoreModel.Rd

This file was deleted.

10 changes: 5 additions & 5 deletions man/checkOutliers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions man/computeLambda.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 15 additions & 13 deletions man/computeOutliersQCScore.Rd → man/computeOutliersQScore.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading