Batch adjusting and scaling the dataset #948
Replies: 1 comment 2 replies
-
So, following up on this, when I do normalize by slide the primary problem I encounter would be that the distribution now includes negative numbers: # Un-normalized
summary(as.vector(gobj@expression$cell$rna$normalized@exprMat))
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 0.0000 0.0000 0.0000 0.8786 0.0000 11.1888
gobj %>%
adjustGiottoMatrix(
batch_columns = 'list_ID',
update_slot = 'normalized'
) -> gobj
# normalized already exists and will be replaced with new values
summary(as.vector(gobj@expression$cell$rna$normalized@exprMat))
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# -0.955590 -0.081362 0.005135 0.847343 0.540294 12.286635 This doesn't cause problems with most of the downstream functions until I get to ligand-receptor cell-cell communication, where I will get a warning for Warning message:
In eval(jsub, SDenv, parent.frame()) : NaNs produced The NAs are in the |
Beta Was this translation helpful? Give feedback.
-
Hello, linking this in with #945 and #862. I am looking at a merged sections across multiple slides, so for instance the wild type vehicle group, on slides A, B, and C. and I want to merge the three and process together as the wild type vehicle group. The question is how to properly account for slide differences?
Potentially, it could simply be:
where
list_ID
is a column with slide numbers. However, I noticed this doesn't update thescaled
slot, and there isn't a function that independently scales the data outside ofnormalizeGiotto
. Looking through a few tutorials (CosMx, seqfish mini, seqfish Cortex), it would appear most downstream function calls all reference either the normalized slot, or else for the heatmaps they seem to re-scale the data on the fly (what I assume "rescaled" is inplotHeatmap
).Is there a way to regenerate the scaled slot? And is there a function that will use it if you do?
As an aside,
adjustGiottoMatrix
is in the tutorials a couple times regressing outnr_feats
andtotal_expr
. This would I imagine pretty much remove any batch effect that impacts the whole slide, though that would in effect turn feature expression into feature expression residuals. Is there a rationale there for doing that. I think in seurat at least, I have had...not great success doing DE testing on residuals.Beta Was this translation helpful? Give feedback.
All reactions