SpatialHackathon / SpaceHack2023

MIT No Attribution
16 stars 3 forks source link

Maple will not work in our benchmarking setting #320

Closed Jieran-S closed 2 months ago

Jieran-S commented 2 months ago

Hi,

Maple is a model that requires Multi-sample dataset input to generate labels for individual samples (see publication (esp Fig. 1) and the code snippet below), whereas in our cases we input individual samples from a dataset. This method might not work under our framework.

The code from their fit_maple function:

  if(is.null(covars))
  {
    print("Note, no supplied covariates. Will use orig.ident as sample indicator.")
    sample <- as.factor(meta[,"orig.ident"])
    W <- as.matrix(stats::model.matrix(~ sample))
    rownames(W) <- rownames(meta)

Whenever I run it within our system, it returns an error as generally our orig.ident has only one level for each sample we input.

error message:

Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 'as.matrix': contrasts can be applied only to factors with 2 or more levels

@shdam Could you check if this is the case or any workaround? I can put Maple as a low-priority implementation for now.

shdam commented 2 months ago

Hmm, I thought it would work anyway since the single-sample tests went well.. Oh well, it is built on spruce, which may then be the actual method that should be implemented, as that is for single samples.

shdam commented 2 months ago

I just saw that spruce is no longer maintained, so perhaps we should exclude maple as well, as it uses spruce.

Jieran-S commented 2 months ago

If it can work without error, I'd be happy to include the method. But I keep on getting the aforementioned error message. Did you have the same experience? Do you think there's any workaround?

shdam commented 2 months ago

Hmm, it would probably need some universal covariate to not use sample ID. However, using spruce instead would require minimal changes. Essentially only these two lines would need changing: library(maple) -> library(spruce) - since it is already installed in the environment. And: maple_results <- fit_maple( -> maple_results <- fit_spruce(

Of course, it would then make sense to rename the method to spruce, but this change should make the method run, and maple is essentially just a multi-sample version of spruce anyway.

Jieran-S commented 2 months ago

Aha I see! Thanks for the suggestion. I will try to run it after the modification.

We should also dicuss a bit whether to keep the method in the next meeting, given that it's no longer maintained.

shdam commented 2 months ago

Yeah, it's unfortunate since it seemed like a decent method, but the P.I. behind it now works in industry. I am curious to hear how it performs :)

Jieran-S commented 2 months ago

Changed to spruce and it seems to work. Close the issue for now