FertigLab / CoGAPS

Bayesian MCMC matrix factorization algorithm
https://www.bioconductor.org/packages/release/bioc/html/CoGAPS.html
BSD 3-Clause "New" or "Revised" License
61 stars 17 forks source link

patternMarkers 'all' returning empty lists #102

Closed kwoyshner closed 3 months ago

kwoyshner commented 4 months ago

Hi! I am trying to obtain patternMarkers from a cogaps result object using the following code: pMarks <- patternMarkers(NMF, threshold = "all", lp = NA, axis = 1)

It returns values for the scores and ranks how I would expect, but there are no patternMarkers for every pattern -- which seems weird.

image image

The 'cut' version does return patternMarkers, but the output is formatted slightly differently than that returned by 'all' (each list isn't named by the pattern name), and there is a warning message I haven't seen before when using this function.

image image

I am using R 4.3.0 and CoGAPS 3.24.0 (installed 5/2/24). I have never run into this issue before, but I had just reinstalled CoGAPS.

Looking into the patternMarkers code here (lines 480-490): image If I print the first few elements of thresholdTest it looks like a named list, but if I print the gene followed by names(gene) for each, the names are NULL

image

I'm not sure if this is happening for anyone else. Please let me know if you need any other details!

dimalvovs commented 4 months ago

related https://github.com/FertigLab/CoGAPS/pull/78

dimalvovs commented 4 months ago

confirmed warning in threshold = "cut"

test_that("patternMarkers work with threshold = 'cut' yields no warning", {
    #set up
    data(GIST)
    res <- CoGAPS(GIST.data_frame, nIterations=1000,
                  seed=1, messages=FALSE)

    test <- patternMarkers(res, threshold = "cut")
    expect_no_warning(length(test$PatternMarkers), 0)
})
dimalvovs commented 4 months ago

confirmed empty markers with threshold = 'all'

test_that("patternMarkers work with threshold = 'all' for general mode", {
    #set up
    data(GIST)
    res <- CoGAPS(GIST.data_frame, nIterations=1000,
                  seed=1, messages=FALSE)

    test <- patternMarkers(res, threshold = "all")
    marker_lengths <- sapply(test$PatternMarkers, length)
    expect_equal(sum(marker_lengths > 0), length(marker_lengths))
})
dimalvovs commented 4 months ago

the problem with warnings generated in case of threshold='cut' comes from the non-matching dimensions of As and Ps during the scaling and sweeping . For the testdata trained on nPatterns=7, the dimensions of A and P that are fed into here https://github.com/FertigLab/CoGAPS/blob/cc8c42cd2a9dc9c99e63e22dba076fabfdb8461e/R/methods-CogapsResult.R#L437 are:

[1] 1363    7
[1] 9 7