# These examples require some setup.
#
# First, we will generate a gene set network from CERNO example
# data, containing multiple distance metrics, as well as pathways
# data. We begin by subsetting the CERNO data for significant results:
sig_pathways.cerno <- subset( Bai_CiHep_DN.cerno, adj.P.Val <= 0.05 )
# Now create a gene set collection containing just the gene sets
# with significant CERNO results, by subsetting Bai_gsc.tmod using
# the gene set IDs as keys:
sig_pathways.tmod <- Bai_gsc.tmod[sig_pathways.cerno$ID]
# And obtain a background gene set from differential expression data:
background_genes <- toupper( rownames( Bai_CiHep_v_Fib2.de ) )
# Create a GSNData object containing Jaccard indices:
sig_pathways.GSN <-
buildGeneSetNetworkJaccard(geneSetCollection = sig_pathways.tmod,
ref.background = background_genes )
# Within the same object, add an 'stlf' (Single Tail Log Fisher)
# distance matrix:
sig_pathways.GSN <-
buildGeneSetNetworkSTLF( object = sig_pathways.GSN )
# Now import the CERNO data:
sig_pathways.GSN <- gsnAddPathwaysData( sig_pathways.GSN,
pathways_data = sig_pathways.cerno )
# Use gsn_distances() to see what distances are stored in the
# GSNData object:
gsn_distances( sig_pathways.GSN )
# Should return: "jaccard" "stlf"
# See what the default distance is:
gsn_default_distance( sig_pathways.GSN )
# Returns: "stlf". Let's change the default distannce
# to "jaccard":
gsn_default_distance( sig_pathways.GSN ) <- "jaccard"
# Let's examine what the ID column is:
pw_id_col( sig_pathways.GSN )
# Returns: "ID"
pw_id_col( sig_pathways.GSN ) <- "ID"
# This is equivalent to the following code. When
# invoked on the left side of an assignment, R uses
# *syntactic sugar* to comvert the call to:
sig_pathways.GSN <- `pw_id_col<-`( object = sig_pathways.GSN,
value = "ID" )
# On the other hand, the following returns an error
# because there is no column in the pathways dataframe
# named "invalid.name":
class( try( pw_id_col( sig_pathways.GSN ) <- "invalid.name" ) )
# "try-error"
# Likewise we can get and set the value of stat_col
# and sig_order:
pw_stat_col(sig_pathways.GSN )
# Returns "adj.P.Val". Let's set it to "AUC"
pw_stat_col(sig_pathways.GSN) <- "AUC"
# And likewise, sig_order:
pw_sig_order(sig_pathways.GSN) # "loToHi"
pw_sig_order(sig_pathways.GSN) <- "hiToLo"
# For 2-channel GSNA analyses, we can set the values
# of stat_col_2 and sig_order_2:
pw_stat_col_2(sig_pathways.GSN )
# Returns NULL. Let's set it to "P.Value"
pw_stat_col_2(sig_pathways.GSN) <- "P.Value"
# And likewise, sig_order:
pw_sig_order_2(sig_pathways.GSN) # NULL
pw_sig_order(sig_pathways.GSN) <- "loToHi"
# pw_n_col() works the same way to set n_col:
pw_n_col(sig_pathways.GSN) # "N1"
pw_n_col(sig_pathways.GSN) <- "N1"
# And also, pw_type()
pw_type(sig_pathways.GSN) # "cerno"
# For setting via pw_type, the value is not
# currently checked, since pathways data may
# be of many types:
pw_type(sig_pathways.GSN) <- "other"
pw_type(sig_pathways.GSN) # "other"
Run the code above in your browser using DataLab