Compute n_species dynamically

This commit is contained in:
Elias Projahn 2021-10-20 11:20:20 +02:00
parent bf6df6af86
commit b2402ea997
2 changed files with 10 additions and 2 deletions

1
data.R
View file

@ -65,7 +65,6 @@ genes <- geposan::genes[, .(
id, id,
name, name,
chromosome, chromosome,
n_species,
suggested = name %chin% genes_suggested_tpe_old, suggested = name %chin% genes_suggested_tpe_old,
verified = name %chin% genes_verified_tpe_old verified = name %chin% genes_verified_tpe_old
)] )]

View file

@ -69,8 +69,17 @@ server <- function(input, output, session) {
by.y = "id" by.y = "id"
) )
# Count included species from the preset per gene.
genes_n_species <- distances[
species %chin% preset$species_ids,
.(n_species = .N),
by = "gene"
]
setkey(genes_n_species, gene)
# Exclude genes with too few species. # Exclude genes with too few species.
results[n_species >= input$n_species] results[genes_n_species[gene, n_species] >= input$n_species]
}) })
# Rank the results. # Rank the results.