neurogenomics / MAGMA_Celltyping

Find causal cell-types underlying complex trait genetics
https://neurogenomics.github.io/MAGMA_Celltyping
71 stars 31 forks source link

Bug in check_inputs_to_magma_celltype_analysis #9

Closed alexandruioanvoda closed 5 years ago

alexandruioanvoda commented 5 years ago

Found a fatal bug (fortunately, easily fixable) in check_inputs_to_magma_celltype_analysis() while running the tutorial.

> ctAssocsLinear = calculate_celltype_associations(ctd,gwas_sumstats_path,genome_ref_path=genome_ref_path,specificity_species = "human")
Error in check_inputs_to_magma_celltype_analysis(ctd, gwas_sumstats_path,  : 
  CTD should have quantiles. Send to 'prepare.quantile.groups' before calling this function.

I was confused, because I already ran ctd = prepare.quantile.groups(ctd,specificity_species="human",numberOfBins=40) successfully, so I looked further:

> names(ctd[[2]])
[1] "specificity"                "mean_exp"                   "linear_normalised_mean_exp" "specificity_quantiles"      "spec_dist"                 
[6] "specDist_quantiles"        
> "quantiles" %in% names(ctd[[2]])
[1] FALSE
> "specificity_quantiles" %in% names(ctd[[2]])
[1] TRUE

So there you have it, https://github.com/NathanSkene/MAGMA_Celltyping/blob/a844adf590af9f25014a319626484f124e046a88/R/check_inputs_to_magma_celltype_analysis.r#L26

This line ^ needs to be modified into: if(!"specificity_quantiles" %in% names(ctd[[annotLevel]])){stop("CTD should have quantiles. Send to 'prepare.quantile.groups' before calling this function.")}

alexandruioanvoda commented 5 years ago

And as a consequence of the changes between the last features added to MAGMA.Celltyping, these lines need to be modified too (from $quantiles to $specificity_quantiles) in order to avoid errors:

https://github.com/NathanSkene/MAGMA_Celltyping/blob/a844adf590af9f25014a319626484f124e046a88/R/map_specificity_to_entrez.r#L29 https://github.com/NathanSkene/MAGMA_Celltyping/blob/a844adf590af9f25014a319626484f124e046a88/R/map_specificity_to_entrez.r#L32 https://github.com/NathanSkene/MAGMA_Celltyping/blob/a844adf590af9f25014a319626484f124e046a88/R/map_specificity_to_entrez.r#L39 https://github.com/NathanSkene/MAGMA_Celltyping/blob/a844adf590af9f25014a319626484f124e046a88/R/map_specificity_to_entrez.r#L41

kevmanderson commented 5 years ago

Alternative solution: add ctd[[i]]$quantiles = ctd[[i]]$specificity_quantiles before running pipeline

NathanSkene commented 5 years ago

Hi Alex & Kevin, thanks again for mentioning those bugs. I think I've fixed this now. Sorry it took a few days to fix (if you know any good bioinformaticians looking for work in London I could use another pair of hands!).