DavisLaboratory / standR

Spatial transcriptomics analyses and decoding in R
https://davislaboratory.github.io/standR/
Other
15 stars 3 forks source link

issue with prepareSpatialDecon() function #23

Closed sciotlos closed 5 months ago

sciotlos commented 8 months ago

Hello,

I'm trying to run spatial deconvolution on a GeoMx data set, and I'm getting an error running prepareSpatialDecon(). The error has to do with the NegProbes but the error message is confusing, because I do indeed specify rmNegProbe=T.

Any ideas what I'm doing wrong? The code I used is below, and also the counts, sample annotations, and feature annotations I'm using as input. Appreciate your help!

countFile <- read_tsv("counts.tsv") %>% as.data.frame()
sampleAnnoFile <- read_tsv("sample_annotation.tsv") %>% as.data.frame()
featureAnnoFile <- read_tsv("feature_annotation.tsv") %>% as.data.frame()

spd <- readGeoMx(countFile, sampleAnnoFile, featureAnnoFile, rmNegProbe = T, NegProbeName = "NegProbe-WTX")
spd_tmm <- geomxNorm(spd, method = "TMM")
spd_tmm <- prepareSpatialDecon(spd_tmm)

Error in prepareSpatialDecon(spe = spd_tmm, negProbeName = "NegProbe-WTX" NegProbe-WTX must be included in the dataset. Perhaps specify rmNegProbe=TRUE when using readGeoMx

When I check out the metadata, it does look like the negative probes were correctly identified:

spd@metadata$NegProbes Mxa_001 Mxa_003 Mxa_004 Mxa_005 NegProbe-WTX_1 653 268 179 181
NegProbe-WTX_2 506 254 163 149
NegProbe-WTX_3 551 231 195 175
NegProbe-WTX_4 521 255 176 133
NegProbe-WTX_5 331 169 138 93

I've also tried setting rmNegProbe = F, which results in a different error:

spd <- readGeoMx(countFile, sampleAnnoFile, featureAnnoFile, rmNegProbe = F) Error in .rowNamesDF<-(x, value = value) : duplicate 'row.names' are not allowed In addition: Warning message: non-unique value when setting 'row.names': 'NegProbe-WTX'

Has anyone run into this error before? Is the input not properly formatted and I'm not catching it? Finally, here is how the input data looks. I took this straight from the GeoMx study's "initial data" export.

head(countFile) TargetName Mxa_001 Mxa_003 Mxa_004 ..... Mxa_0050 1 Pcdhb14 622 344 234 ..... 207 2 Vmn2r65 532 273 191 ..... 199 3 Mboat7 580 338 281 ..... 206 4 Tspan2 431 234 192 ..... 163 5 Olfr849 427 207 185 ..... 157 6 Hbb-bh1 484 239 173 ..... 155

head(sampleAnnoFile) SlideName ScanLabel ROILabel SegmentLabel SegmentDisplayName Origin ... ScanOffsetX ScanOffsetY 1 Slide2 Mxa 001 Mxa_001 Mxa_001 ... 6990 552 2 Slide2 Mxa 003 Mxa_003 Mxa_003 ... 6990 552 3 Slide2 Mxa 004 Mxa_004 Mxa_004 ... 6990 552 4 Slide2 Mxa 005 Mxa_005 Mxa_005 ... 6990 552 5 Slide2 Mxa 006 Mxa_006 Mxa_006 ... 6990 552 6 Slide2 Mxa 008 Mxa_008 Mxa_008 ... 6990 552

head(featureAnnoFile) nProbeName ProbeDisplayName TargetName ... AnalyteType CodeClass ProbePool TargetGroup GeneID 1 26433 Pcdhb14_01 Pcdhb14 ... Endogenous 1 All Targets 93885 2 32703 Vmn2r65_01 Vmn2r65 ... Endogenous 1 All Targets 100009609 3 23510 Mboat7_01 Mboat7 ... Endogenous 1 All Targets 77582 4 31985 Tspan2_01 Tspan2 ... Endogenous 1 All Targets 70747 5 26003 Olfr849_01 Olfr849 ... Endogenous 1 All Targets 258520

OnkarMulay commented 8 months ago

same error

ningbioinfo commented 8 months ago

Hi @sciotlos ,

For multiple negative probes in the dataset, can you try the following steps?

  1. Make sure the negative probes in your data have unique names. This is causing the error you had when running readGeoMx with rmNegProbe set to FALSE.
  2. When running prepareSpatialDecon, run it with the parameters negProbeName and pool.