Nanostring-Biostats / SpatialDecon

The SpatialDecon library implements the SpatialDecon algorithm for mixed cell deconvolution in spatial gene expression datasets. (This algorithm also works in bulk expression profiling data.)
MIT License
33 stars 8 forks source link

Error on runspatialdecon and spatialdecon - Only 3 genes are shared between norm and X - this may not be enough to support accurate deconvolution #50

Closed borexino closed 1 year ago

borexino commented 1 year ago

I'm trying to perform SpatialDecon on GeoMX DSP data prior filtered following the NanoString R guide .

For runspatialdeconI'm using code from here:

res = runspatialdecon(object = target_demoData,     # My S4 obj
                      norm_elt = "q_norm",          # Referring to Q3 norm for WTA/CTA  w/ or w/o custom spike-ins. As suggested by the above mentioned guide
                      raw_elt = "exprs",            # Raw exprs
                      X = safeTME,
                      align_genes = TRUE)

I get this:

Schermata 2023-04-25 alle 10 10 18

In addition, I tried spatialdecon following the code from here :

res = spatialdecon(norm = norm,
                   bg = bg,
                   X = safeTME,
                   align_genes = TRUE)

Output:

Schermata 2023-04-25 alle 10 18 48

head(bg)

Schermata 2023-04-25 alle 10 20 28

I checked for identical genes present in safeTME and in bg:

# Detect same genes present in safeTME and in bg 
intersect(rownames(safeTME), rownames(bg))
[1] "C2" "C3" "C7"

Only those 3 genes are detected as the same between objects.

But, when I capitalize with toupper:

# Detect same genes present in safeTME and in bg 
length(intersect(rownames(safeTME), toupper(rownames(bg))))
[1] 627

So, let's capitalize norm and bg rownames

rownames(bg) <- toupper(rownames(bg))
rownames(norm) <- toupper(rownames(norm))
 res = spatialdecon(norm = norm,
                    bg = bg,
                    X = safeTME,
                    align_genes = TRUE)
There were 34 warnings (use warnings() to see them)
 str(res)
List of 10
 $ beta            : num [1:18, 1:92] 1.1052 0.0637 2.8569 0 0.611 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:18] "macrophages" "mast" "B.naive" "B.memory" ...
  .. ..$ : chr [1:92] "001DSP-1001660018721-A-A02.dcc" "002DSP-1001660018721-A-A03.dcc" "003DSP-1001660018721-A-A04.dcc" "004DSP-1001660018721-A-A05.dcc" ...
 $ sigmas          : num [1:18, 1:18, 1:92] 4.70167 -0.00546 0.3476 -0.39018 0.11352 ...
  ..- attr(*, "dimnames")=List of 3
  .. ..$ : chr [1:18] "macrophages" "mast" "B.naive" "B.memory" ...
  .. ..$ : chr [1:18] "macrophages" "mast" "B.naive" "B.memory" ...
  .. ..$ : chr [1:92] "001DSP-1001660018721-A-A02.dcc" "002DSP-1001660018721-A-A03.dcc" "003DSP-1001660018721-A-A04.dcc" "004DSP-1001660018721-A-A05.dcc" ...
 $ yhat            : num [1:627, 1:92] 27.1 22.8 51.7 21 20.3 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:627] "ACAP1" "ACER1" "ACP5" "ADAM12" ...
  .. ..$ : chr [1:92] "001DSP-1001660018721-A-A02.dcc" "002DSP-1001660018721-A-A03.dcc" "003DSP-1001660018721-A-A04.dcc" "004DSP-1001660018721-A-A05.dcc" ...
 $ resids          : num [1:627, 1:92] 0.1088 0.2098 0.0252 0.1562 0.2034 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:627] "ACAP1" "ACER1" "ACP5" "ADAM12" ...
  .. ..$ : chr [1:92] "001DSP-1001660018721-A-A02.dcc" "002DSP-1001660018721-A-A03.dcc" "003DSP-1001660018721-A-A04.dcc" "004DSP-1001660018721-A-A05.dcc" ...
 $ p               : num [1:18, 1:92] 0.61 0.709 0.839 1 0.787 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:18] "macrophages" "mast" "B.naive" "B.memory" ...
  .. ..$ : chr [1:92] "001DSP-1001660018721-A-A02.dcc" "002DSP-1001660018721-A-A03.dcc" "003DSP-1001660018721-A-A04.dcc" "004DSP-1001660018721-A-A05.dcc" ...
 $ t               : num [1:18, 1:92] 0.51 0.373 0.203 0 0.271 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:18] "macrophages" "mast" "B.naive" "B.memory" ...
  .. ..$ : chr [1:92] "001DSP-1001660018721-A-A02.dcc" "002DSP-1001660018721-A-A03.dcc" "003DSP-1001660018721-A-A04.dcc" "004DSP-1001660018721-A-A05.dcc" ...
 $ se              : num [1:18, 1:92] 2.168 0.171 14.049 14.045 2.258 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:18] "macrophages" "mast" "B.naive" "B.memory" ...
  .. ..$ : chr [1:92] "001DSP-1001660018721-A-A02.dcc" "002DSP-1001660018721-A-A03.dcc" "003DSP-1001660018721-A-A04.dcc" "004DSP-1001660018721-A-A05.dcc" ...
 $ prop_of_all     : num [1:18, 1:92] 0.0832 0.0048 0.215 0 0.046 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:18] "macrophages" "mast" "B.naive" "B.memory" ...
  .. ..$ : chr [1:92] "001DSP-1001660018721-A-A02.dcc" "002DSP-1001660018721-A-A03.dcc" "003DSP-1001660018721-A-A04.dcc" "004DSP-1001660018721-A-A05.dcc" ...
 $ prop_of_nontumor: num [1:18, 1:92] 0.0832 0.0048 0.215 0 0.046 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:18] "macrophages" "mast" "B.naive" "B.memory" ...
  .. ..$ : chr [1:92] "001DSP-1001660018721-A-A02.dcc" "002DSP-1001660018721-A-A03.dcc" "003DSP-1001660018721-A-A04.dcc" "004DSP-1001660018721-A-A05.dcc" ...
 $ X               : num [1:627, 1:18] 0.013597 0.001793 3.092894 0.013735 0.000285 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:627] "ACAP1" "ACER1" "ACP5" "ADAM12" ...
  .. ..$ : chr [1:18] "macrophages" "mast" "B.naive" "B.memory" ...

Could it be a bug? Thanks

borexino commented 1 year ago

Feel free to delete the issue!

maddygriz commented 1 year ago

This issue has been addressed here