Browse code

updated docs

Catherine Ross authored on 23/03/2021 23:37:33
Showing 16 changed files

... ...
@@ -2,6 +2,7 @@
2 2
 
3 3
 export(plotDotPlot)
4 4
 export(plotFemap)
5
+export(prepInput)
5 6
 export(readPathways)
6 7
 export(runFedup)
7 8
 export(writeFemap)
8 9
deleted file mode 100644
... ...
@@ -1,17 +0,0 @@
1
-% Generated by roxygen2: do not edit by hand
2
-% Please edit documentation in R/data.R
3
-\docType{data}
4
-\name{backgroundGene}
5
-\alias{backgroundGene}
6
-\title{Example vector of human genes to use as background set for enrichment.}
7
-\format{
8
-a character vector with 10208 elements (gene IDs)
9
-}
10
-\usage{
11
-data(backgroundGene)
12
-}
13
-\description{
14
-Script to generate data
15
-system.file("data-raw", "genes.R", package = "fedup")
16
-}
17
-\keyword{datasets}
18 0
new file mode 100644
... ...
@@ -0,0 +1,23 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/data.R
3
+\docType{data}
4
+\name{geneDouble}
5
+\alias{geneDouble}
6
+\title{Example list of a background set and two sets of test genes to use for
7
+enrichment analysis.}
8
+\format{
9
+a named list with three vector elements, one common background
10
+gene vector and two test gene vectors.
11
+}
12
+\usage{
13
+data(geneDouble)
14
+}
15
+\description{
16
+Raw Excel data file (Sup Tab 2) is available from
17
+\url{https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7566881/}
18
+}
19
+\details{
20
+Script to prepare data
21
+system.file("inst", "script", "genes.R", package = "fedup")
22
+}
23
+\keyword{datasets}
0 24
new file mode 100644
... ...
@@ -0,0 +1,23 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/data.R
3
+\docType{data}
4
+\name{geneMulti}
5
+\alias{geneMulti}
6
+\title{Example list of a background set and multiple sets of test genes
7
+to use for enrichment analysis.}
8
+\format{
9
+a named list with thirteen vector elements, one common background
10
+gene vector and twelve test gene vectors.
11
+}
12
+\usage{
13
+data(geneMulti)
14
+}
15
+\description{
16
+Raw Excel data file (Sup Tab 2) is available from
17
+\url{https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7566881/}
18
+}
19
+\details{
20
+Script to prepare data
21
+system.file("inst", "script", "genes.R", package = "fedup")
22
+}
23
+\keyword{datasets}
0 24
new file mode 100644
... ...
@@ -0,0 +1,23 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/data.R
3
+\docType{data}
4
+\name{geneSingle}
5
+\alias{geneSingle}
6
+\title{Example list of a background set and single set of test genes to use for
7
+enrichment analysis.}
8
+\format{
9
+a named list with two vector elements, one common background
10
+gene vector and one test gene vector.
11
+}
12
+\usage{
13
+data(geneSingle)
14
+}
15
+\description{
16
+Raw Excel data file (Sup Tab 2) is available from
17
+\url{https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7566881/}
18
+}
19
+\details{
20
+Script to prepare data
21
+system.file("inst", "script", "genes.R", package = "fedup")
22
+}
23
+\keyword{datasets}
... ...
@@ -11,7 +11,7 @@ a named list of 1437 vectors
11 11
 data(pathwaysGMT)
12 12
 }
13 13
 \description{
14
-Raw GMT file is available from
14
+GMT file is available from
15 15
 \url{http://download.baderlab.org/EM_Genesets/November_17_2020/Human/symbol}
16 16
 }
17 17
 \details{
... ...
@@ -11,7 +11,7 @@ a named list of 317 vectors
11 11
 data(pathwaysTXT)
12 12
 }
13 13
 \description{
14
-Raw Excel data file (S5) is available from
14
+Raw data file (S5) is available from
15 15
 \url{https://boonelab.ccbr.utoronto.ca/supplement/costanzo2016/}
16 16
 }
17 17
 \details{
... ...
@@ -11,7 +11,7 @@ a named list of 317 vectors
11 11
 data(pathwaysXLSX)
12 12
 }
13 13
 \description{
14
-Raw Excel data file (S5) is available from
14
+Raw data file (S5) is available from
15 15
 \url{https://boonelab.ccbr.utoronto.ca/supplement/costanzo2016/}
16 16
 }
17 17
 \details{
... ...
@@ -2,7 +2,7 @@
2 2
 % Please edit documentation in R/plot.R
3 3
 \name{plotDotPlot}
4 4
 \alias{plotDotPlot}
5
-\title{Visualizes pathway enrichment and depletion using ggplot.}
5
+\title{Visualizes fedup enrichment and depletion results using ggplot.}
6 6
 \usage{
7 7
 plotDotPlot(
8 8
     df,
... ...
@@ -19,49 +19,61 @@ plotDotPlot(
19 19
 )
20 20
 }
21 21
 \arguments{
22
-\item{df}{(data.frame) table with fedup enrichment results to plot.}
22
+\item{df}{(data.frame) table with fedup results generated via
23
+\link[fedup]{runFedup}}
23 24
 
24
-\item{xVar}{(char) x-axis variable (must be a column value in \code{df}).}
25
+\item{xVar}{(char) x-axis variable (must be a column value in \code{df})}
25 26
 
26
-\item{yVar}{(char) y-axis variable (must be a column value in \code{df}).}
27
+\item{yVar}{(char) y-axis variable (must be a column value in \code{df})}
27 28
 
28
-\item{xLab}{(char) x-axis label (default \code{xVar} value).}
29
+\item{xLab}{(char) x-axis label (default \code{xVar} value)}
29 30
 
30
-\item{yLab}{(char) y-axis label (default NULL).}
31
+\item{yLab}{(char) y-axis label (default NULL)}
31 32
 
32
-\item{pTitle}{(char) plot title (default NULL).}
33
+\item{pTitle}{(char) plot title (default NULL)}
33 34
 
34
-\item{fillVar}{(char) point fill variable (default NULL).}
35
+\item{fillVar}{(char) point fill variable (default NULL)}
35 36
 
36
-\item{fillCol}{(char) point fill colours (default NULL).}
37
+\item{fillCol}{(char) point fill colours (default NULL)}
37 38
 
38
-\item{fillLab}{(char) point fill label (default \code{fillVar} value).}
39
+\item{fillLab}{(char) point fill label (default \code{fillVar} value)}
39 40
 
40
-\item{sizeVar}{(char) point size variable (default NULL).}
41
+\item{sizeVar}{(char) point size variable (default NULL)}
41 42
 
42
-\item{sizeLab}{(char) point size label (default \code{sizeVar} value).}
43
+\item{sizeLab}{(char) point size label (default \code{sizeVar} value)}
43 44
 }
44 45
 \value{
45
-object returned from ggplot with the enrichment dot plot.
46
+Object returned from ggplot with the enrichment dot plot.
46 47
 }
47 48
 \description{
48
-Visualizes pathway enrichment and depletion using ggplot.
49
+This function supports any combination of numeric x-y variables
50
+to plot from fedup results. The list outputted by \link[fedup]{runFedup}
51
+must first be converted to a data.frame before plotting (see examples for
52
+sample use).
49 53
 }
50 54
 \examples{
51
-data(testGene)
52
-data(backgroundGene)
55
+data(geneDouble)
53 56
 data(pathwaysGMT)
54
-fedup_res <- runFedup(testGene, backgroundGene, pathwaysGMT)
55
-fedup_plot <- fedup_res[which(fedup_res$qvalue < 0.05), ]
56
-fedup_plot$log10qvalue <- -log10(fedup_plot$qvalue + 1e-10)
57
-fedup_plot$pathway <- gsub("\\\\\%.*", "", fedup_plot$pathway)
58
-plotDotPlot(
59
-    df = fedup_plot,
57
+suppressMessages(library(dplyr))
58
+suppressMessages(library(tidyr))
59
+fedupRes <- runFedup(geneDouble, pathwaysGMT)
60
+# Prepare dataframe from fedup results
61
+fedupPlot <- fedupRes \%>\%
62
+    bind_rows(.id = "set") \%>\%
63
+    separate(col = "set", into = c("set", "sign"), sep = "_") \%>\%
64
+    subset(qvalue < 0.01) \%>\%
65
+    mutate(log10qvalue = -log10(qvalue)) \%>\%
66
+    mutate(pathway = gsub("\\\\\%.*", "", pathway)) \%>\%
67
+    as.data.frame()
68
+# Plot
69
+p <- plotDotPlot(
70
+    df = fedupPlot,
60 71
     xVar = "log10qvalue",
61 72
     yVar = "pathway",
62
-    xLab = "-log10(Qvalue)",
63
-    fillVar = "status",
64
-    fillLab = "Enrichment\nstatus",
73
+    xLab = "-log10(qvalue)",
74
+    fillVar = "sign",
75
+    fillLab = "Genetic interaction",
76
+    fillCol = c("#0077f1", "#fcde24"),
65 77
     sizeVar = "fold_enrichment",
66 78
     sizeLab = "Fold enrichment"
67 79
 )
... ...
@@ -2,58 +2,66 @@
2 2
 % Please edit documentation in R/femap.R
3 3
 \name{plotFemap}
4 4
 \alias{plotFemap}
5
-\title{Draws a network representation of overlaps among enriched and depleted
6
-pathways using EnrichmentMap (EM) in Cytoscape.}
5
+\title{Draws a network representation of overlaps among pathway enrichment
6
+results using EnrichmentMap (EM) in Cytoscape.}
7 7
 \usage{
8 8
 plotFemap(
9 9
     gmtFile,
10
-    resultsFile,
10
+    resultsFolder,
11 11
     pvalue = 1,
12 12
     qvalue = 1,
13
+    chartData = "NES_VALUE",
14
+    hideNodeLabels = FALSE,
13 15
     netName = "generic",
14 16
     netFile = "png"
15 17
 )
16 18
 }
17 19
 \arguments{
18
-\item{gmtFile}{(char) path to GMT file (must be an absolute path).}
20
+\item{gmtFile}{(char) absolute path to GMT file (generated via
21
+\link[fedup]{writePathways})}
19 22
 
20
-\item{resultsFile}{(char) path to file with fedup results
21
-(must be an absolute path).}
23
+\item{resultsFolder}{(char) absolute path to folder with fedup results
24
+(generated via \link[fedup]{writeFemap})}
22 25
 
23
-\item{pvalue}{(numeric) pvalue cutoff. Pathways with a higher pvalue
24
-will not be included in the EM (value between 0 and 1; default 1).}
26
+\item{pvalue}{(numeric) pvalue cutoff (value between 0 and 1; default 1)}
25 27
 
26
-\item{qvalue}{(numeric) qvalue cutoff. Pathways with a higher qvalue
27
-will not be included in the EM (value between 0 and 1; default 1).}
28
+\item{qvalue}{(numeric) qvalue cutoff (value between 0 and 1; default 1)}
28 29
 
29
-\item{netName}{(char) name for EM in Cytoscape (default generic).}
30
+\item{chartData}{(char) node chart data (one of NES_VALUE, P_VALUE,
31
+FDR_VALUE, PHENOTYPES, DATA_SET, EXPRESSION_SET, or NONE;
32
+default = NES_VALUE)}
30 33
 
31
-\item{netFile}{(char) name of output image. Supports png, pdf, svg,
32
-jpeg image formats.}
34
+\item{hideNodeLabels}{(logical) if TRUE hides the node label in the EM;
35
+cluster labels generated via AutoAnnotate remain visible}
36
+
37
+\item{netName}{(char) name for EM in Cytoscape (default generic)}
38
+
39
+\item{netFile}{(char) name of output image (supports png, pdf, svg,
40
+jpeg image formats)}
33 41
 }
34 42
 \value{
35
-file name of image to which the network is exported and an open
43
+File name of image to which the network is exported and an open
36 44
 session of Cytoscape (side effect of plotting EM). NULL if Cytoscape
37 45
 is not running locally.
38 46
 }
39 47
 \description{
40
-Draws a network representation of overlaps among enriched and depleted
41
-pathways using EnrichmentMap (EM) in Cytoscape.
48
+Draws a network representation of overlaps among pathway enrichment
49
+results using EnrichmentMap (EM) in Cytoscape.
42 50
 }
43 51
 \examples{
44
-data(testGene)
45
-data(backgroundGene)
52
+data(geneDouble)
46 53
 data(pathwaysGMT)
54
+fedupRes <- runFedup(geneDouble, pathwaysGMT)
55
+resultsFolder <- tempdir()
56
+writeFemap(fedupRes, resultsFolder)
47 57
 gmtFile <- tempfile("pathwaysGMT", fileext = ".gmt")
48
-fedupRes <- runFedup(testGene, backgroundGene, pathwaysGMT)
49
-resultsFile <- tempfile("fedupRes", fileext = ".txt")
50
-netFile <- tempfile("fedup_EM", fileext = ".png")
51 58
 writePathways(pathwaysGMT, gmtFile)
52
-writeFemap(fedupRes, resultsFile)
59
+netFile <- tempfile("fedup_EM", fileext = ".png")
53 60
 plotFemap(
54 61
     gmtFile = gmtFile,
55
-    resultsFile = resultsFile,
62
+    resultsFolder = resultsFolder,
56 63
     qvalue = 0.05,
64
+    hideNodeLabels = TRUE,
57 65
     netName = "fedup_EM",
58 66
     netFile = netFile
59 67
 )
60 68
new file mode 100644
... ...
@@ -0,0 +1,36 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/genes.R
3
+\name{prepInput}
4
+\alias{prepInput}
5
+\title{Prepares input gene list for \link[fedup]{runFedup}.}
6
+\usage{
7
+prepInput(setName, ...)
8
+}
9
+\arguments{
10
+\item{setName}{(char) character vector naming gene vectors passed to
11
+\code{...} (must include "background" (case sensitive)).}
12
+
13
+\item{...}{(char) \code{n} vectors with at least one background set of genes
14
+and any number of test genes.}
15
+}
16
+\value{
17
+List of length \code{n} with gene vectors corresponding to those
18
+passed to \code{...}.
19
+}
20
+\description{
21
+This function takes any number of test genes and a common
22
+background set of genes and properly formats them for to pass to
23
+\link[fedup]{runFedup} \code{gene} argument.
24
+}
25
+\examples{
26
+# Raw gene data file
27
+genesFile <- system.file("extdata",
28
+    "NIHMS1587165-supplement-1587165_Sup_Tab_2.txt", package = "fedup")
29
+genes <- read.delim(genesFile, h = TRUE, as.is = TRUE)
30
+# Prepare gene vectors
31
+b <- unique(genes[, "gene"])
32
+set1 <- unique(genes[which(genes$FASN_merge < -0.4), "gene"])
33
+set2 <- unique(genes[which(genes$FASN_merge > 0.4), "gene"])
34
+setName <- c("background", "negative", "positive")
35
+geneDouble <- prepInput(setName, b, set1, set2)
36
+}
... ...
@@ -2,8 +2,7 @@
2 2
 % Please edit documentation in R/pathways.R
3 3
 \name{readPathways}
4 4
 \alias{readPathways}
5
-\title{Returns a list of pathways from various file formats.
6
-Currently supports the following file format: gmt, txt, xlsx.}
5
+\title{Returns a list of pathways from various file formats.}
7 6
 \usage{
8 7
 readPathways(
9 8
     pathwayFile,
... ...
@@ -15,29 +14,30 @@ readPathways(
15 14
 )
16 15
 }
17 16
 \arguments{
18
-\item{pathwayFile}{(char) path to file with pathway annotations.}
17
+\item{pathwayFile}{(char) path to file with pathway annotations}
19 18
 
20 19
 \item{header}{(logical) whether \code{pathwayFile} has a header
21
-(default FALSE).}
20
+(default FALSE)}
22 21
 
23
-\item{pathCol}{(char or int) column name or number with pathway identifiers.
24
-For use with non-GMT input files (eg "Pathway.ID" or 2; default NULL).}
22
+\item{pathCol}{(char or int) column name or number with pathway identifiers
23
+(for use with non-GMT input files (eg "Pathway.ID" or 2; default NULL))}
25 24
 
26
-\item{geneCol}{(char or int) column name or number with gene identifiers.
27
-For use with non-GMT input files (eg "Gene.ID" or 5; default NULL).}
25
+\item{geneCol}{(char or int) column name or number with gene identifiers
26
+(for use with non-GMT input files (eg "Gene.ID" or 5; default NULL))}
28 27
 
29 28
 \item{minGene}{(integer) minimum number of genes to be considered
30
-in a pathway (default 1).}
29
+in a pathway (default 1)}
31 30
 
32 31
 \item{maxGene}{(integer) maximum number of genes to be considered
33
-in a pathway (default Inf).}
32
+in a pathway (default Inf)}
34 33
 }
35 34
 \value{
36
-a list of vectors with pathway annotations.
35
+A list of vectors with pathway annotations.
37 36
 }
38 37
 \description{
39
-Returns a list of pathways from various file formats.
40
-Currently supports the following file format: gmt, txt, xlsx.
38
+This function supports custom pathway annotations to use
39
+for fedup pathway enrichment analysis. Current file formats supported are
40
+gmt, txt, and xlsx.
41 41
 }
42 42
 \examples{
43 43
 pathways <- readPathways(
... ...
@@ -2,43 +2,51 @@
2 2
 % Please edit documentation in R/fedup.R
3 3
 \name{runFedup}
4 4
 \alias{runFedup}
5
-\title{Runs gene enrichment and depletion analysis for a list of pathways.}
5
+\title{Runs pathway enrichment and depletion analysis using a Fisher's
6
+exact test.}
6 7
 \usage{
7
-runFedup(testGene, backgroundGene, pathways)
8
+runFedup(genes, pathways)
8 9
 }
9 10
 \arguments{
10
-\item{testGene}{(char) vector of genes to use as test set.}
11
+\item{genes}{(list) named list of vectors with background genes and \code{n}
12
+test genes.}
11 13
 
12
-\item{backgroundGene}{(char) vector of genes to use as background set.}
13
-
14
-\item{pathways}{(list) list of vectors with pathway annotations.}
14
+\item{pathways}{(list) named list of vectors with pathway annotations.}
15 15
 }
16 16
 \value{
17
-table of pathway enrichment and depletion results. Rows represent
18
-tested pathways. Columns represent:
17
+List of length \code{n} with table(s) of pathway enrichment and
18
+depletion results. Rows represent tested pathways. Columns represent:
19 19
 \itemize{
20 20
     \item pathway -- name of the pathway, corresponds to
21 21
         names(\code{pathways});
22 22
     \item size -- size of the pathway;
23
-    \item real_frac -- fraction of \code{testGene} members in pathway;
24
-    \item expected_frac -- fraction of \code{backgroundGene} members in
23
+    \item real_frac -- fraction of test gene members in pathway;
24
+    \item expected_frac -- fraction of background gene members in
25 25
         pathway;
26 26
     \item fold_enrichment -- fold enrichment measure,
27 27
         evaluates as \code{real_frac} / \code{expected_frac};
28 28
     \item status -- indicator that pathway is enriched or depleted for
29
-        \code{testGene} members;
30
-    \item real_gene -- vector of \code{testGene} gene members annotated
29
+        test gene members;
30
+    \item real_gene -- vector of test gene members annotated
31 31
         to \code{pathways};
32 32
     \item pvalue -- enrichment p-value calculated via Fisher's exact test;
33 33
     \item qvalue -- BH-adjusted p-value
34 34
 }
35 35
 }
36 36
 \description{
37
-Runs gene enrichment and depletion analysis for a list of pathways.
37
+This function takes a list of test genes and a common background
38
+set to calculate enrichment and depletion for a list of pathways. The method
39
+allows for fast and efficient testing of multiple gene sets of interest.
38 40
 }
39 41
 \examples{
40
-data(testGene)
41
-data(backgroundGene)
42 42
 data(pathwaysGMT)
43
-fedup_res <- runFedup(testGene, backgroundGene, pathwaysGMT)
43
+# Run analysis with a single test set
44
+data(geneSingle)
45
+fedupRes <- runFedup(geneSingle, pathwaysGMT)
46
+# Run analysis with two test sets
47
+data(geneDouble)
48
+fedupRes <- runFedup(geneDouble, pathwaysGMT)
49
+# Run analysis with multiple test sets
50
+data(geneMulti)
51
+fedupRes <- runFedup(geneMulti, pathwaysGMT)
44 52
 }
45 53
deleted file mode 100644
... ...
@@ -1,17 +0,0 @@
1
-% Generated by roxygen2: do not edit by hand
2
-% Please edit documentation in R/data.R
3
-\docType{data}
4
-\name{testGene}
5
-\alias{testGene}
6
-\title{Example vector of human genes to use as test set for enrichment.}
7
-\format{
8
-a character vector with 190 elements (gene IDs)
9
-}
10
-\usage{
11
-data(testGene)
12
-}
13
-\description{
14
-Script to prepare data
15
-system.file("inst", "script", "genes.R", package = "fedup")
16
-}
17
-\keyword{datasets}
... ...
@@ -4,20 +4,19 @@
4 4
 \alias{writeFemap}
5 5
 \title{Writes an enrichment dataset file for use in Cytoscape EnrichmentMap.}
6 6
 \usage{
7
-writeFemap(df, resultsFile)
7
+writeFemap(results, resultsFolder)
8 8
 }
9 9
 \arguments{
10
-\item{df}{(data.frame) table with fedup enrichment results.
11
-(see runFedup() for column descriptions)}
10
+\item{results}{(list) list with ouput results from \link[fedup]{runFedup}}
12 11
 
13
-\item{resultsFile}{(char) name of output results file.}
12
+\item{resultsFolder}{(char) name of folder to store result file(s)}
14 13
 }
15 14
 \value{
16
-table of gene enrichment and depletion results formatted as a
15
+Table of pathway enrichment and depletion results formatted as a
17 16
 'Generic results file'. Rows represent tested pathways. Columns represent:
18 17
 \itemize{
19 18
     \item pathway -- pathway ID (must match pathway IDs in the GMT file
20
-        provided to plotFemap());
19
+        provided to \link[fedup]{plotFemap};
21 20
     \item description -- pathway name or description;
22 21
     \item pvalue -- enrichment pvalue;
23 22
     \item qvalue -- BH-corrected pvalue;
... ...
@@ -29,10 +28,9 @@ table of gene enrichment and depletion results formatted as a
29 28
 Writes an enrichment dataset file for use in Cytoscape EnrichmentMap.
30 29
 }
31 30
 \examples{
32
-data(testGene)
33
-data(backgroundGene)
31
+data(geneDouble)
34 32
 data(pathwaysGMT)
35
-fedupRes <- runFedup(testGene, backgroundGene, pathwaysGMT)
36
-resultsFile <- tempfile("fedupRes", fileext = ".txt")
37
-writeFemap(fedupRes, resultsFile)
33
+fedupRes <- runFedup(geneDouble, pathwaysGMT)
34
+resultsFolder <- tempdir()
35
+writeFemap(fedupRes, resultsFolder)
38 36
 }
... ...
@@ -7,9 +7,9 @@
7 7
 writePathways(pathways, gmtFile)
8 8
 }
9 9
 \arguments{
10
-\item{pathways}{(list) named list of vectors.}
10
+\item{pathways}{(list) named list of vectors}
11 11
 
12
-\item{gmtFile}{(char) name of output GMT file.}
12
+\item{gmtFile}{(char) name of output GMT file}
13 13
 }
14 14
 \value{
15 15
 GMT-formatted file. Rows represent pathways. Columns represent: