Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Area analysis on Data.table not working in Spectre 1.2.0 #195

Open
RoryCostell opened this issue Aug 30, 2024 · 2 comments
Open

Area analysis on Data.table not working in Spectre 1.2.0 #195

RoryCostell opened this issue Aug 30, 2024 · 2 comments

Comments

@RoryCostell
Copy link

Hi, I have updated my Spectre to 1.2.0, and also updated R and R studio to the latest build.

When I run the new advanced spatial workflow, everything works great and the addition of the regions and cell types is great.

However, when I run the third script - advanced quantitative analysis, and I run the area analysis, it seems unable to run the area analysis by region for all the ROIs, giving the error:

Smooth muscle cells to Podoplanin+ fibroblasts
Smooth muscle cells to Podoplanin+aSMA+ fibroblasts
Smooth muscle cells to Podoplanin+aSMA+Factor 13a+ fibroblasts
---- Smooth muscle cells to Smooth muscle cells
Region: Tumour
Error in gtools::permutations(n = length(reg.pops), r = 2, V = reg. pops, :
bad value of n

It this because some of the cell types are not present in the region: Tumour?

The area analysis is working fine with the old code, setting the region to total and ignoring the individual regions for the area analysis.

Please let me know if you need more information and I will reproduce the error.

Thank you very much!
Screenshot 2024-08-30 at 11 42 59 AM

@tomashhurst
Copy link
Member

@RoryCostell hey mate, we will have a look! This most often comes up if there are some ROIs that don't have all the region types present. Was an oversight on our part when writing the code (we had larger ROIs where there was always representation across them). But if it was working before the update then perhaps something went wrong when we moved to v1.2.

@RoryCostell
Copy link
Author

RoryCostell commented Sep 1, 2024

@RoryCostell hey mate, we will have a look! This most often comes up if there are some ROIs that don't have all the region types present. Was an oversight on our part when writing the code (we had larger ROIs where there was always representation across them). But if it was working before the update then perhaps something went wrong when we moved to v1.2.

Thanks Tom!

That must be it, as the ROIs are based on a TMA of separate regions. The workaround I've used for now is to redefine area.table to area.totals, with the previous checks above.

` ### Some checks

    as.matrix(unique(cell.dat[[roi.col]]))
    as.matrix(unique(cell.dat[[group.col]]))
    as.matrix(unique(cell.dat[[region.col]]))
    as.matrix(unique(cell.dat[[batch.col]]))
    area.table
    
    as.matrix(unique(cell.dat[[pop.col]]))
    
    ## Temporary until region fix
    **area.totals
    cell.dat$Region <- 'Total'
    region.col <- 'Region'**

### Run area analysis on the DATA.TABLE

    reg.dat <- run.spatial.analysis(dat = cell.dat, 
                                    sample.col = roi.col, 
                                    pop.col = pop.col, 
                                    annot.cols = batch.col, group.col,
                                    region.col = region.col, 
                                    **area.table = area.totals**) ## Also calculate on total by default
    
    reg.dat[,c(1:10)]
    `

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants