neurogenomics/MAGMA_Celltyping

cell type data no longer compatible with EWCE

roxyisat-rex opened this issue · 3 comments

The cell type data contained in MAGMA_Celltyping is no long compatible with EWCE.
The ctd in MAGMA (I used the Zeisel 2018), did not contain "annot" which is needed for EWCE to run.
Tracing back the functions, we pinned it to the EWCE:::is_celltypedataset function. "annot" (cell level data that states which cluster each cell is assigned to) is needed.

> EWCE:::is_celltypedataset(MAGMA.Celltyping::ctd_Zeisel2018)
[1] FALSE

The CTD in MAGMA.Celltyping should still be compatible with all the EWCE functions used in MAGMA.Celltyping.

For uses outside of MAGMA.Celltyping, you can edit the CTDs as needed. However, I'll make a note to update the CTDs in the future when we eventually move them to the official ewceData R package.

I decided to make a short-term fix in the meantime by adding dummy $annot data.frames to each CTD. They simply contain the celltype names. In the future, these will ideally contain more detailed information (e.g. celltype acronym-full name mappings, # cells per celltype).

arg_list <- rlang::fn_fmls(fn = MAGMA.Celltyping::get_ctd)
ctd_names <- eval(arg_list$ctd_name)
for(d in ctd_names){
    message(d)
    ctd <- MAGMA.Celltyping::get_ctd(ctd_name = d)
    for(lv in seq_len(length(ctd))){
        if(!"annot" %in% names(ctd[[lv]])){
            ctd[[lv]]$annot <- data.frame(celltype=colnames(ctd[[lv]]$mean_exp))
        } 
    }
    names(ctd) <- paste0("level",seq_len(length(ctd)))
    save_path <- file.path(tempdir(),paste0(d,".rda"))
    save(ctd, file = save_path) 
    piggyback::pb_upload(file = save_path,
                         repo = "neurogenomics/MAGMA_Celltyping",
                         overwrite = TRUE)
}