Browse code

Added data docs, edited setup file in test suite. Also added script for generating the RData objects

Federico Marini authored on 29/11/2019 10:09:32
Showing 7 changed files

... ...
@@ -128,6 +128,7 @@ importFrom(tidyr,pivot_longer)
128 128
 importFrom(tidyr,separate_rows)
129 129
 importFrom(utils,browseURL)
130 130
 importFrom(utils,citation)
131
+importFrom(utils,data)
131 132
 importFrom(utils,read.delim)
132 133
 importFrom(utils,sessionInfo)
133 134
 importFrom(viridis,viridis)
134 135
new file mode 100644
... ...
@@ -0,0 +1,40 @@
1
+#' A sample `DESeqResults` object
2
+#'
3
+#' A sample `DESeqResults` object, generated in the `DESeq2` framework
4
+#'
5
+#' @details This `DESeqResults` object on the data from the `macrophage` package
6
+#' has been created comparing IFNg treated samples vs naive samples, accounting
7
+#' for the different cell lines included.
8
+#'
9
+#' Details on how this object has been created are included in the `create_gt_data.R`
10
+#' script, included in the `scripts` folder of the `GeneTonic` package.
11
+#'
12
+#' @references Alasoo, et al. "Shared genetic effects on chromatin and gene
13
+#' expression indicate a role for enhancer priming in immune response",
14
+#' Nature Genetics, January 2018 doi: 10.1038/s41588-018-0046-7.
15
+#'
16
+#' @name res_macrophage_IFNg_vs_naive
17
+#' @docType data
18
+NULL
19
+
20
+
21
+#' A sample `res_enrich` object
22
+#'
23
+#' A sample `res_enrich` object, generated with the `topGOtable` function (from
24
+#' the `pcaExplorer` package).
25
+#'
26
+#' @details This `res_enrich` object on the data from the `macrophage` package
27
+#' has been created by analyzing downstream the differentially expressed genes
28
+#' when comparing IFNg treated samples vs naive samples, accounting
29
+#' for the different cell lines included.
30
+#'
31
+#' Details on how this object has been created are included in the `create_gt_data.R`
32
+#' script, included in the `scripts` folder of the `GeneTonic` package.
33
+#'
34
+#' @references Alasoo, et al. "Shared genetic effects on chromatin and gene
35
+#' expression indicate a role for enhancer priming in immune response",
36
+#' Nature Genetics, January 2018 doi: 10.1038/s41588-018-0046-7.
37
+#'
38
+#' @name topgoDE_macrophage_IFNg_vs_naive
39
+#' @docType data
40
+NULL
... ...
@@ -43,7 +43,7 @@
43 43
 #' @importFrom shinyWidgets dropdownButton tooltipOptions
44 44
 #' @import SummarizedExperiment
45 45
 #' @importFrom tidyr separate_rows pivot_longer
46
-#' @importFrom utils read.delim sessionInfo browseURL citation
46
+#' @importFrom utils read.delim sessionInfo browseURL citation data
47 47
 #' @importFrom visNetwork renderVisNetwork visIgraph visNetworkOutput visOptions
48 48
 #' @importFrom viridis viridis
49 49
 #'
50 50
new file mode 100644
... ...
@@ -0,0 +1,51 @@
1
+library(GeneTonic)
2
+library(macrophage)
3
+data(gse)
4
+
5
+# dds object -------------------------------------------------------------------
6
+library(DESeq2)
7
+dds_macrophage <- DESeqDataSet(gse, design = ~line + condition)
8
+rownames(dds_macrophage) <- substr(rownames(dds_macrophage), 1, 15)
9
+# no need to save this one, can be readily generated
10
+
11
+# res object -------------------------------------------------------------------
12
+keep <- rowSums(counts(dds_macrophage) >= 10) >= 6
13
+dds_macrophage <- dds_macrophage[keep, ]
14
+library("org.Hs.eg.db")
15
+dds_macrophage <- DESeq(dds_macrophage)
16
+# vst_macrophage <- vst(dds_macrophage)
17
+res_macrophage_IFNg_vs_naive <- results(dds_macrophage,
18
+                                        contrast = c("condition", "IFNg", "naive"),
19
+                                        lfcThreshold = 1, alpha = 0.05)
20
+res_macrophage_IFNg_vs_naive$SYMBOL <- rowData(dds_macrophage)$SYMBOL
21
+library("AnnotationDbi")
22
+# de_symbols_IFNg_vs_naive <- res_macrophage_IFNg_vs_naive[(!(is.na(res_macrophage_IFNg_vs_naive$padj))) & (res_macrophage_IFNg_vs_naive$padj <= 0.05), "SYMBOL"]
23
+de_symbols_IFNg_vs_naive <- deseqresult2df(res_macrophage_IFNg_vs_naive, FDR = 0.05)$SYMBOL
24
+bg_ids <- rowData(dds_macrophage)$SYMBOL[rowSums(counts(dds_macrophage)) > 0]
25
+save(res_macrophage_IFNg_vs_naive, file = "data/res_de_macrophage.RData", compress = "xz")
26
+
27
+# res_enrich object ------------------------------------------------------------
28
+library("topGO")
29
+topgoDE_macrophage_IFNg_vs_naive <-
30
+  pcaExplorer::topGOtable(de_symbols_IFNg_vs_naive,
31
+                          bg_ids,
32
+                          ontology = "BP",
33
+                          mapping = "org.Hs.eg.db",
34
+                          geneID = "symbol",
35
+                          topTablerows = 500)
36
+write.table(topgoDE_macrophage_IFNg_vs_naive,
37
+            "inst/extdata/topgotable_res_IFNg_vs_naive.txt",
38
+            sep = "\t")
39
+save(topgoDE_macrophage_IFNg_vs_naive, file = "data/res_enrich_macrophage.RData", compress = "xz")
40
+topgoDE_macrophage_IFNg_vs_naive <-
41
+  read.table(system.file("extdata", "topgotable_res_IFNg_vs_naive.txt", package = "GeneTonic"),
42
+             stringsAsFactors = FALSE)
43
+
44
+# annotation object ------------------------------------------------------------
45
+library("org.Hs.eg.db")
46
+anno_df <- data.frame(
47
+  gene_id = rownames(dds_macrophage),
48
+  gene_name = mapIds(org.Hs.eg.db, keys = rownames(dds_macrophage), column = "SYMBOL", keytype = "ENSEMBL"),
49
+  stringsAsFactors = FALSE,
50
+  row.names = rownames(dds_macrophage)
51
+)
0 52
new file mode 100644
... ...
@@ -0,0 +1,22 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/GeneTonic-data.R
3
+\docType{data}
4
+\name{res_macrophage_IFNg_vs_naive}
5
+\alias{res_macrophage_IFNg_vs_naive}
6
+\title{A sample \code{DESeqResults} object}
7
+\description{
8
+A sample \code{DESeqResults} object, generated in the \code{DESeq2} framework
9
+}
10
+\details{
11
+This \code{DESeqResults} object on the data from the \code{macrophage} package
12
+has been created comparing IFNg treated samples vs naive samples, accounting
13
+for the different cell lines included.
14
+
15
+Details on how this object has been created are included in the \code{create_gt_data.R}
16
+script, included in the \code{scripts} folder of the \code{GeneTonic} package.
17
+}
18
+\references{
19
+Alasoo, et al. "Shared genetic effects on chromatin and gene
20
+expression indicate a role for enhancer priming in immune response",
21
+Nature Genetics, January 2018 doi: 10.1038/s41588-018-0046-7.
22
+}
0 23
new file mode 100644
... ...
@@ -0,0 +1,24 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/GeneTonic-data.R
3
+\docType{data}
4
+\name{topgoDE_macrophage_IFNg_vs_naive}
5
+\alias{topgoDE_macrophage_IFNg_vs_naive}
6
+\title{A sample \code{res_enrich} object}
7
+\description{
8
+A sample \code{res_enrich} object, generated with the \code{topGOtable} function (from
9
+the \code{pcaExplorer} package).
10
+}
11
+\details{
12
+This \code{res_enrich} object on the data from the \code{macrophage} package
13
+has been created by analyzing downstream the differentially expressed genes
14
+when comparing IFNg treated samples vs naive samples, accounting
15
+for the different cell lines included.
16
+
17
+Details on how this object has been created are included in the \code{create_gt_data.R}
18
+script, included in the \code{scripts} folder of the \code{GeneTonic} package.
19
+}
20
+\references{
21
+Alasoo, et al. "Shared genetic effects on chromatin and gene
22
+expression indicate a role for enhancer priming in immune response",
23
+Nature Genetics, January 2018 doi: 10.1038/s41588-018-0046-7.
24
+}
0 25
similarity index 98%
1 26
rename from tests/testthat/setup_genetonic.R
2 27
rename to tests/testthat/setuptests_genetonic.R
... ...
@@ -52,12 +52,11 @@ dds_macrophage <- dds_macrophage[keep, ]
52 52
 dds_unnormalized <- dds_macrophage
53 53
 
54 54
 library("org.Hs.eg.db")
55
-# dds_macrophage <- addIds(dds_macrophage, "SYMBOL")
56 55
 dds_macrophage <- DESeq(dds_macrophage)
57 56
 vst_macrophage <- vst(dds_macrophage)
58 57
 res_macrophage_IFNg_vs_naive <- results(dds_macrophage,
59 58
                                         contrast = c("condition", "IFNg", "naive"),
60
-                                        lfcThreshold = 1, alpha = 0.01)
59
+                                        lfcThreshold = 1, alpha = 0.05)
61 60
 summary(res_macrophage_IFNg_vs_naive)
62 61
 res_macrophage_IFNg_vs_naive$SYMBOL <- rowData(dds_macrophage)$SYMBOL
63 62