Closed bschilder closed 1 year ago
I've added a new argument called sctSpecies_origin
, which allows users to independently specify the current gene format of the CTD as well as the original species that the CTD came from.
This chooses the correct background (mouse + human) and keeps 17 gene hits.
sct_data <- ewceData::ctd()
sct_data2 <- EWCE::standardise_ctd(ctd = sct_data, input_species = "mouse", output_species = "human")
hits <- ewceData::example_genelist()
full_results <- EWCE::bootstrap_enrichment_test(
sct_data = sct_data2,
hits = hits,
reps = 10,
annotLevel = 1,
sctSpecies = "human",
sctSpecies_origin = "mouse",
genelistSpecies = "human")
1 core(s) assigned as workers (11 reserved).
Generating gene background for mouse x human ==> human
Gathering ortholog reports.
Retrieving all genes using: homologene.
Retrieving all organisms available in homologene.
Mapping species name: human
Common name mapping found for human
1 organism identified from search: 9606
Gene table with 19,129 rows retrieved.
Returning all 19,129 genes from human.
-- mouse
Retrieving all genes using: homologene.
Retrieving all organisms available in homologene.
Mapping species name: mouse
Common name mapping found for mouse
1 organism identified from search: 10090
Gene table with 21,207 rows retrieved.
Returning all 21,207 genes from mouse.
--
--
Preparing gene_df.
data.frame format detected.
Extracting genes from Gene.Symbol.
21,207 genes extracted.
Converting mouse ==> human orthologs using: homologene
Retrieving all organisms available in homologene.
Mapping species name: mouse
Common name mapping found for mouse
1 organism identified from search: 10090
Retrieving all organisms available in homologene.
Mapping species name: human
Common name mapping found for human
1 organism identified from search: 9606
Checking for genes without orthologs in human.
Extracting genes from input_gene.
17,355 genes extracted.
Extracting genes from ortholog_gene.
17,355 genes extracted.
Checking for genes without 1:1 orthologs.
Dropping 131 genes that have multiple input_gene per ortholog_gene (many:1).
Dropping 498 genes that have multiple ortholog_gene per input_gene (1:many).
Filtering gene_df with gene_map
Adding input_gene col to gene_df.
Adding ortholog_gene col to gene_df.
=========== REPORT SUMMARY ===========
Total genes dropped after convert_orthologs :
4,725 / 21,207 (22%)
Total genes remaining after convert_orthologs :
16,482 / 21,207 (78%)
--
=========== REPORT SUMMARY ===========
16,482 / 21,207 (77.72%) target_species genes remain after ortholog conversion.
16,482 / 19,129 (86.16%) reference_species genes remain after ortholog conversion.
Gathering ortholog reports.
Retrieving all genes using: homologene.
Retrieving all organisms available in homologene.
Mapping species name: human
Common name mapping found for human
1 organism identified from search: 9606
Gene table with 19,129 rows retrieved.
Returning all 19,129 genes from human.
-- human
Retrieving all genes using: homologene.
Retrieving all organisms available in homologene.
Mapping species name: human
Common name mapping found for human
1 organism identified from search: 9606
Gene table with 19,129 rows retrieved.
Returning all 19,129 genes from human.
--
=========== REPORT SUMMARY ===========
19,129 / 19,129 (100%) target_species genes remain after ortholog conversion.
19,129 / 19,129 (100%) reference_species genes remain after ortholog conversion.
16,482 intersect background genes used.
Standardising CellTypeDataset
Checking gene list inputs.
Running without gene size control.
17 hit gene(s) remain after filtering.
Computing gene scores.
Using previously sampled genes.
Computing gene counts.
Testing for enrichment in 7 cell types...
Sorting results by p-value.
Computing BH-corrected q-values.
2 significant cell type enrichment results @ q<0.05 :
CellType annotLevel p fold_change sd_from_mean q
1 microglia 1 0 1.892713 4.874007 0
2 astrocytes_ependymal 1 0 1.212996 1.074574 0
Just to confirm, this is the same results you get if you run the mapping internally:
sct_data <- ewceData::ctd()
hits <- ewceData::example_genelist()
full_results <- EWCE::bootstrap_enrichment_test(
sct_data = sct_data,
hits = hits,
reps = 10,
annotLevel = 1,
sctSpecies = "mouse",
genelistSpecies = "human")
1 core(s) assigned as workers (11 reserved).
Generating gene background for mouse x human ==> human
Gathering ortholog reports.
Retrieving all genes using: homologene.
Retrieving all organisms available in homologene.
Mapping species name: human
Common name mapping found for human
1 organism identified from search: 9606
Gene table with 19,129 rows retrieved.
Returning all 19,129 genes from human.
-- mouse
Retrieving all genes using: homologene.
Retrieving all organisms available in homologene.
Mapping species name: mouse
Common name mapping found for mouse
1 organism identified from search: 10090
Gene table with 21,207 rows retrieved.
Returning all 21,207 genes from mouse.
--
--
Preparing gene_df.
data.frame format detected.
Extracting genes from Gene.Symbol.
21,207 genes extracted.
Converting mouse ==> human orthologs using: homologene
Retrieving all organisms available in homologene.
Mapping species name: mouse
Common name mapping found for mouse
1 organism identified from search: 10090
Retrieving all organisms available in homologene.
Mapping species name: human
Common name mapping found for human
1 organism identified from search: 9606
Checking for genes without orthologs in human.
Extracting genes from input_gene.
17,355 genes extracted.
Extracting genes from ortholog_gene.
17,355 genes extracted.
Checking for genes without 1:1 orthologs.
Dropping 131 genes that have multiple input_gene per ortholog_gene (many:1).
Dropping 498 genes that have multiple ortholog_gene per input_gene (1:many).
Filtering gene_df with gene_map
Adding input_gene col to gene_df.
Adding ortholog_gene col to gene_df.
=========== REPORT SUMMARY ===========
Total genes dropped after convert_orthologs :
4,725 / 21,207 (22%)
Total genes remaining after convert_orthologs :
16,482 / 21,207 (78%)
--
=========== REPORT SUMMARY ===========
16,482 / 21,207 (77.72%) target_species genes remain after ortholog conversion.
16,482 / 19,129 (86.16%) reference_species genes remain after ortholog conversion.
Gathering ortholog reports.
Retrieving all genes using: homologene.
Retrieving all organisms available in homologene.
Mapping species name: human
Common name mapping found for human
1 organism identified from search: 9606
Gene table with 19,129 rows retrieved.
Returning all 19,129 genes from human.
-- human
Retrieving all genes using: homologene.
Retrieving all organisms available in homologene.
Mapping species name: human
Common name mapping found for human
1 organism identified from search: 9606
Gene table with 19,129 rows retrieved.
Returning all 19,129 genes from human.
--
=========== REPORT SUMMARY ===========
19,129 / 19,129 (100%) target_species genes remain after ortholog conversion.
19,129 / 19,129 (100%) reference_species genes remain after ortholog conversion.
16,482 intersect background genes used.
Standardising CellTypeDataset
Checking gene list inputs.
Running without gene size control.
17 hit gene(s) remain after filtering.
Computing gene scores.
Using previously sampled genes.
Computing gene counts.
Testing for enrichment in 7 cell types...
Sorting results by p-value.
Computing BH-corrected q-values.
2 significant cell type enrichment results @ q<0.05 :
CellType annotLevel p fold_change sd_from_mean q
1 microglia 1 0 1.977958 3.654319 0
2 astrocytes_ependymal 1 0 1.371805 2.678270 0
Indeed, the results are the same (in that the same celltypes are enriched). Increasing the bootstrap iterations would likely make the specific numbers more convergent.
Note that this may have affected some of your analyses @KittyMurphy, depending on how you ran them
1. Bug description
I just found an issue that can occur when the CTD has previously been converted from one species to another (e.g. mouse genes to human orthologs) and then fed into
bootstrap_enrichment_test
. The user will correctly setsctSpecies
to "human", as the CTD is already in human gene format. But this same argument gets passed toorthogene::create_background
, which intreprets the CTD as having originally come from a human, which is didn't. To create the appropriate background, you would need to take into account that the CTD originally comes from mouse.Note that this is not a problem when the CTD is passed in as the original mouse genes and
sctSpecies="mouse"
, bc the function internally does the mouse --> human conversion (and resassigning thesctSpecies
variable) after creating the background. This how we demonstrate to useEWCE
in the function example.Expected behaviour
Appropriate background is chosen regardless of current ortholog format of the CTD.
2. Reproducible example
Code
Console output
Because the background is wrong, the number of remaining hit genes is 0, and an error occurs.
3. Session info