### R code from vignette source 'usingpcxnData.Rnw'
### Encoding: UTF-8

###################################################
### code chunk number 1: usingpcxnData.Rnw:35-77
###################################################
# Use the pcxn library
library(pcxn)
library(pcxnData)

# Load  the data
ds = c("cp_gs_v5.1", "gobp_gs_v5.1", "h_gs_v5.1","pathprint.Hs.gs",
    "pathCor_CPv5.1_dframe","pathCor_GOBPv5.1_dframe","pathCor_Hv5.1_dframe",
    "pathCor_pathprint_v1.2.3_dframe","pathCor_CPv5.1_unadjusted_dframe",
    "pathCor_GOBPv5.1_unadjusted_dframe","pathCor_Hv5.1_unadjusted_dframe",
    "pathCor_pathprint_v1.2.3_unadjusted_dframe")

data(list = ds)

# Explore the static extendable network by focusing on single pathways and their
# 10 most correlated neighbours in the pathprint collection
pcxn.obj <- pcxn_explore(collection = "pathprint",
                    query_geneset = "Alzheimer's disease (KEGG)",
                    adj_overlap = FALSE,
                    top = 10,
                    min_abs_corr = 0.05,
                    max_pval = 0.05)

# Analyse relationships between groups of pathways shown to be enriched in the
# collection by gene set enrichment
pcxn.obj <- pcxn_analyze(collection = "pathprint",
            phenotype_0_genesets = c("ABC transporters (KEGG)",
                                    "ACE Inhibitor Pathway (Wikipathways)",
                                    "AR down reg. targets (Netpath)"),
            phenotype_1_genesets = c("DNA Repair (Reactome)"),
            adj_overlap = FALSE,
            top = 10,
            min_abs_corr = 0.05,
            max_pval = 0.05 )

# Generate the heatmap for any pcxn object generated by the
# explore or analyze function
hm <- pcxn_heatmap(pcxn.obj , cluster_method = "complete")

# Get the gene members (Entrez Ids and symbols) of any pathway/geneset in the
# data
gene_members <- pcxn_gene_members(pathway_name = "Alzheimer's disease (KEGG)")