R/combineResults.R

#' combineResults
#'
#' Extract and combine results from all analyses for all genes
#'
#' @param con A \code{SQLiteConnection} object to the database containing the data
#' @param genes A vector of ensembl gene ids
#' @return a data frame
#' @export
combineResults <- function(con, genes) {

    sql <- "
    select
	t1.gene_id, t1.gene_name, t1.entrezid, t1.seqnames, t1.start,
    t2.mu1, t2.mu2, t2.sigma, t2.delta, t2.pi_value, t2.BI, t2.bisep_pval,
    t3.N_lof, t3.N_protein_coding, t3.pct_lof, t3.pct_protein_coding, t3.mutations,
    t4.count_paralogs, t4.paralog_ids,
    t5.dmelanogaster_ortholog_ids, t5.dmelanogaster_homolog_orthology_type, t5.allele_count_fly, t5.lethal_pct_fly,
    t6.celegans_ortholog_ids, t6.celegans_homolog_orthology_type, t6.allele_count_worm, t6.lethal_pct_worm

    from human_genes t1
    left join bisep_results t2 on t1.gene_id = t2.gene_id
    left join mutation_analysis_results t3 on t1.gene_id = t3.gene_id
    left join count_paralogs_output t4 on t1.gene_id = t4.ensembl_gene_id
    left join flymine_analysis_output t5 on t1.gene_id = t5.ensembl_gene_id
    left join wormmine_analysis_output t6 on t1.gene_id = t6.ensembl_gene_id

    "

    results <- DBI::dbGetQuery(con, sql) %>%
        dplyr::filter(gene_id %in% genes) %>%
        as.data.frame()

    DBI::dbWriteTable(con, 'combined_results', results, overwrite=T)

    return(results)
}
chapmandu2/CollateralVulnerability2016 documentation built on May 13, 2019, 3:27 p.m.