Closed AMCalejandro closed 1 year ago
I was revisitting this and I thought I would be clearer showing the input data.
I do see you were expecting an unnammed list to store the results after running your example code. However, when I perform the association test, results are stored underl "levels" elements in the list
See here:
# Map GWAS snps to genes # This is basically the out file from
genesOutPath_intelligence <- MAGMA.Celltyping::map_snps_to_genes(
path_formatted = gwas_sumstats_path,
genome_build = "GRCh37",
population = "eur",
N = 111114,force_new = T)
# Loading transcriptome data from the Karolinska instititute
ctd <- MAGMA.Celltyping::get_ctd("ctd_allKI")
ctd_quant =
MAGMA.Celltyping::prepare_quantile_groups(ctd = ctd,
non121_strategy = "drop_both_species",
standardise = TRUE,
input_species = "mouse",
output_species = "human",
numberOfBins = 40)
ctAssocsLinear <- MAGMA.Celltyping::calculate_celltype_associations(
ctd = ctd_quant,
gwas_sumstats_path = gwas_sumstats_path,
magma_dir = NULL,
genesOutCOND = NA,
ctd_species = infer_ctd_species(ctd),
force_new = FALSE)
> names(ctAssocsLinear)
[1] "level1" "level2" "total_baseline_tests_performed" "gwas_sumstats_path"
[5] "analysis_name" "upstream_kb" "downstream_kb"
str(ctAssocsLinear$level1)
List of 1
$ results:'data.frame': 24 obs. of 14 variables:
..$ Celltype : chr [1:24] "astrocytes_ependymal" "Dopaminergic_Adult" "Dopaminergic_Neuroblast" "Embryonic_Dopaminergic_Neuron" ...
..$ OBS_GENES : chr [1:24] "71" "71" "71" "71" ...
..$ BETA : num [1:24] -0.005079 -0.004212 -0.000215 0.00292 -0.005705 ...
..$ BETA_STD : num [1:24] -0.05943 -0.04793 -0.00273 0.03446 -0.0622 ...
..$ SE : num [1:24] 0.00846 0.0085 0.00748 0.0082 0.00951 ...
..$ P : num [1:24] 0.725 0.689 0.511 0.362 0.724 ...
..$ level : int [1:24] 1 1 1 1 1 1 1 1 1 1 ...
..$ Method : chr [1:24] "MAGMA" "MAGMA" "MAGMA" "MAGMA" ...
..$ GCOV_FILE : chr [1:24] "educational_attainment.tsv.35UP.10DOWN.level1.MainRun.gsa.out" "educational_attainment.tsv.35UP.10DOWN.level1.MainRun.gsa.out" "educational_attainment.tsv.35UP.10DOWN.level1.MainRun.gsa.out" "educational_attainment.tsv.35UP.10DOWN.level1.MainRun.gsa.out" ...
..$ CONTROL : chr [1:24] "BASELINE" "BASELINE" "BASELINE" "BASELINE" ...
..$ CONTROL_label : chr [1:24] "BASELINE" "BASELINE" "BASELINE" "BASELINE" ...
..$ log10p : num [1:24] -0.14 -0.162 -0.291 -0.442 -0.14 ...
..$ genesOutCOND : chr [1:24] "NA" "NA" "NA" "NA" ...
..$ EnrichmentMode: chr [1:24] "Linear" "Linear" "Linear" "Linear" ...
Hey Brian,
This sum will always retrieve 0, as far as I am aware. I think what you wanted to do is what I just added?
Based on the code that was edited, it looks like you're talking about the plot_celltype_associations
function. I've updated the title of this PR to clarify.
Regarding the issue, looks like your PR does indeed fix this. Thanks for this! I'll add a unit test as well to ensure this gets checked.
Also, note that MAGMA.Celltyping does not load ggplot2 into the workspace. Probably the user should do this!! ( my bad) But maybe it is safer to do ggplot2::theme_set
Thanks for catching this, I'll make a fix.
I've extended your code to make a fully reproducible example (eg one that i can run all the way through by copying and pasting it into my R console)
gwas_sumstats_path <- MAGMA.Celltyping::get_example_gwas()
# Map GWAS snps to genes # This is basically the out file from
genesOutPath_intelligence <- MAGMA.Celltyping::map_snps_to_genes(
path_formatted = gwas_sumstats_path,
genome_build = "GRCh37",
population = "eur",
N = 111114,force_new = T)
# Loading transcriptome data from the Karolinska instititute
ctd <- MAGMA.Celltyping::get_ctd("ctd_allKI")
ctd_quant =
MAGMA.Celltyping::prepare_quantile_groups(ctd = ctd,
non121_strategy = "drop_both_species",
standardise = TRUE,
input_species = "mouse",
output_species = "human",
numberOfBins = 40)
ctAssocsLinear <- MAGMA.Celltyping::calculate_celltype_associations(
ctd = ctd_quant,
gwas_sumstats_path = gwas_sumstats_path,
magma_dir = NULL,
genesOutCOND = NA,
ctd_species = infer_ctd_species(ctd),
force_new = FALSE)
### Passing in ctAssocsLinear directly ####
figs <- MAGMA.Celltyping::plot_celltype_associations(
ctAssocs = ctAssocsLinear,
ctd = ctd)
I
## Indeed this returns an empty list
figs <- MAGMA.Celltyping::plot_celltype_associations(
ctAssocs = ctAssocsLinear,
ctd = ctd)
Hey Brian,
This sum will always retrieve 0, as far as I am aware. I think what you wanted to do is what I just added?
Also, note that MAGMA.Celltyping does not load ggplot2 into the workspace. Probably the user should do this!! ( my bad) But maybe it is safer to do ggplot2::theme_set