MOFA2 icon indicating copy to clipboard operation
MOFA2 copied to clipboard

Truncation of very long features names can lose uniqueness

Open frederikziebell opened this issue 2 years ago • 2 comments

Here's an example

file <- system.file("extdata", "test_data.RData", package = "MOFA2")
load(file) 
dt$feature[1] <- paste0(paste0(1:20,collapse="_"),"A")
dt$feature[2] <- paste0(paste0(1:20,collapse="_"),"B")
MOFAmodel <- create_mofa(dt)
MOFAmodel <- prepare_mofa(MOFAmodel)
MOFAmodel <- run_mofa(MOFAmodel, use_basilisk = T)

The two feature names are very long. MOFA truncates them, causing a loss of unique feature names, which results in

Error in .quality_control(object, verbose = verbose) : 
!duplicated(unlist(features_names(object))) are not all TRUE

when the trained model is loaded at the end of run_mofa. I suggest to not truncate feature names. If the names are too long for some plots to look nice, it should be the user's burden to make sure names are short. If you truncate, I suggest to at least put a "..." at the end of the feature name to indicate truncation.

This example seems artificial, but in my application, the long feature name was a phosphorylation of a histone protein, which caused the error.

frederikziebell avatar May 29 '22 19:05 frederikziebell

Hi Frederik, thank you for pointing this out. We are working on the splicing events and encountered the same issue as well. I wonder do you have a good idea to circumvent the problem before it was fixed?

hsun3163 avatar Oct 02 '22 16:10 hsun3163

Hi @frederikziebell and @hsun3163, the constrain in the length of feature names should have been fixed in the latest version. Could you please update the mofapy2 python package (just do pip install mofapy2) and reinstall the MOFA2 R package from github (instructions here https://biofam.github.io/MOFA2/installation.html), and let me know if the problem is solved?

If you are using reticulate to make the R-Python connection make sure that you are linking the latest mofapy2 version, and not some previous version you currently have installed.

FYI latest versions should be: MOFA2 R package: 1.7.2 mofapy2 python package: 0.6.6

rargelaguet avatar Oct 05 '22 13:10 rargelaguet