Skip to content

Commit

Permalink
Add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
csoneson committed Jul 3, 2023
1 parent 27b698d commit a442a22
Show file tree
Hide file tree
Showing 23 changed files with 228 additions and 0 deletions.
8 changes: 8 additions & 0 deletions R/doPCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
#' components.}
#' }
#'
#' @examples
#' sce <- readRDS(system.file("extdata", "mq_example", "1356_sce.rds",
#' package = "einprot"))
#' pca <- doPCA(sce, assayName = "log2_LFQ.intensity", ncomponents = 3)
#' pca$plotcoord$PC1_2
#' pca$plotcombined$PC1_2
#' pca$plotpairs
#'
#' @importFrom scater runPCA
#' @importFrom scuttle makePerCellDF
#' @importFrom tibble rownames_to_column
Expand Down
8 changes: 8 additions & 0 deletions R/makeAbundanceExport.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
#'
#' @returns A \code{data.frame} with abundances for significant features.
#'
#' @examples
#' sce <- readRDS(system.file("extdata", "mq_example", "1356_sce.rds",
#' package = "einprot"))
#' names(S4Vectors::metadata(sce)$testres$tests)
#' abExp <- makeAbundanceExport(S4Vectors::metadata(sce)$testres$tests,
#' abundancePrefix = "iBAQ")
#' head(abExp)
#'
#' @importFrom dplyr select filter starts_with contains if_any full_join
#' matches everything
#'
Expand Down
7 changes: 7 additions & 0 deletions R/makeAbundanceHeatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
#'
#' @returns A ComplexHeatmap object.
#'
#' @examples
#' sce <- readRDS(system.file("extdata", "mq_example", "1356_sce.rds",
#' package = "einprot"))
#' hm <- makeAbundanceHeatmap(sce, assayToPlot = "log2_LFQ.intensity",
#' doCenter = TRUE, settings = "report")
#' ComplexHeatmap::draw(hm)
#'
#' @importFrom ComplexHeatmap Heatmap columnAnnotation
#' @importFrom SummarizedExperiment assay assayNames
#' @importFrom grid gpar
Expand Down
13 changes: 13 additions & 0 deletions R/makeiSEEScript.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
#'
#' @returns The path to the generated script.
#'
#' @examples
#' sceFile <- system.file("extdata", "mq_example", "1356_sce.rds",
#' package = "einprot")
#' sce <- readRDS(sceFile)
#' isee <- makeiSEEScript(tempfile(fileext = "_isee.R"), sceFile = sceFile,
#' aName = "LFQ.intensity",
#' tests = S4Vectors::metadata(sce)$testres$tests,
#' assayForPlots = "log2_LFQ.intensity",
#' assayForHeatmaps = "iBAQ",
#' includeFeatureSetTable = FALSE)
#' file.exists(isee)
#' head(readLines(isee), 10)
#'
#' @author Charlotte Soneson
#' @export
#'
Expand Down
6 changes: 6 additions & 0 deletions R/plotImputation.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#'
#' @returns A ggplot object.
#'
#' @examples
#' sce <- readRDS(system.file("extdata", "mq_example", "1356_sce.rds",
#' package = "einprot"))
#' plotImputationDistribution(sce, assayToPlot = "log2_LFQ.intensity",
#' assayImputation = "imputed_LFQ.intensity")
#'
#' @importFrom SummarizedExperiment assay
#' @importFrom tibble rownames_to_column
#' @importFrom tidyr gather
Expand Down
10 changes: 10 additions & 0 deletions R/plotMissingValues.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ plotMissingValuesHeatmap <- function(sce, assayMissing) {
#'
#' @returns A \code{ggplot} object.
#'
#' @examples
#' sce <- readRDS(system.file("extdata", "mq_example", "1356_sce.rds",
#' package = "einprot"))
#' plotFractionDetectedPerSample(SummarizedExperiment::colData(sce))
#'
#' @importFrom ggplot2 ggplot aes theme geom_bar theme_bw labs expand_limits
#' geom_text
#' @importFrom dplyr filter %>%
Expand Down Expand Up @@ -96,6 +101,11 @@ plotFractionDetectedPerSample <- function(dfNA) {
#'
#' @returns A \code{ggplot} object.
#'
#' @examples
#' sce <- readRDS(system.file("extdata", "mq_example", "1356_sce.rds",
#' package = "einprot"))
#' plotDetectedInSamples(SummarizedExperiment::rowData(sce))
#'
#' @importFrom ggplot2 ggplot aes geom_bar labs
#' @importFrom rlang .data
#' @importFrom dplyr filter %>% group_by tally pull mutate
Expand Down
12 changes: 12 additions & 0 deletions R/plotVolcano.R
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,18 @@
#' If \code{baseFileName} is not \code{NULL}, pdf files with volcano
#' plots and bar plots for significant complexes will also be generated.
#'
#' @examples
#' sce <- readRDS(system.file("extdata", "mq_example", "1356_sce.rds",
#' package = "einprot"))
#' tres <- runTest(sce, comparisons = list(c("RBC_ctrl", "Adnp")),
#' testType = "limma", assayForTests = "log2_LFQ.intensity",
#' assayImputation = "imputed_LFQ.intensity")
#' pv <- plotVolcano(sce, tres$tests$Adnp_vs_RBC_ctrl, testType = "limma",
#' comparisonString = "Adnp_vs_RBC_ctrl")
#' pv$gg
#' pv$ggma
#' pv$ggwf
#'
#' @author Charlotte Soneson
#' @export
#' @importFrom ggplot2 geom_point aes labs
Expand Down
19 changes: 19 additions & 0 deletions R/prepareFeatureCollections.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@
#'
#' @returns A list of \code{CharacterList}s (one for each feature collection).
#'
#' @examples
#' sce <- readRDS(system.file("extdata", "mq_example", "1356_sce.rds",
#' package = "einprot"))
#' fc <- prepareFeatureCollections(sce, idCol = "einprotGene",
#' includeFeatureCollections = "complexes",
#' complexDbPath = NULL,
#' speciesInfo = getSpeciesInfo("mouse"),
#' complexSpecies = "all")
#'
#' ## List of complexes, expressed in terms of the row names of sce
#' fc
#'
#' ## Metadata for the complexes
#' S4Vectors::mcols(fc$complexes)
#'
#' @importFrom S4Vectors mcols DataFrame endoapply
#' @importFrom IRanges CharacterList
#' @importFrom methods as
Expand All @@ -82,6 +97,10 @@ prepareFeatureCollections <- function(sce, idCol, includeFeatureCollections,
.assertVector(x = includeFeatureCollections, type = "character",
validValues = c("complexes", "GO"), allowNULL = TRUE)
.assertScalar(x = complexDbPath, type = "character", allowNULL = TRUE)
if (is.null(complexDbPath) && "complexes" %in% includeFeatureCollections) {
complexDbPath <- system.file(EINPROT_COMPLEXES_FILE,
package = "einprot")
}
if (!is.null(complexDbPath)) {
stopifnot(file.exists(complexDbPath))
}
Expand Down
9 changes: 9 additions & 0 deletions R/runTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,15 @@
#' (including only features and feature sets passing the imposed significance
#' thresholds) are saved.
#'
#' @examples
#' sce <- readRDS(system.file("extdata", "mq_example", "1356_sce.rds",
#' package = "einprot"))
#' tres <- runTest(sce, comparisons = list(c("RBC_ctrl", "Adnp")),
#' testType = "limma", assayForTests = "log2_LFQ.intensity",
#' assayImputation = "imputed_LFQ.intensity")
#' head(tres$tests$Adnp_vs_RBC_ctrl)
#' tres$design
#'
#' @importFrom SummarizedExperiment assay rowData colData
#' @importFrom stats model.matrix p.adjust
#' @importFrom limma lmFit treat topTreat cameraPR ids2indices eBayes
Expand Down
9 changes: 9 additions & 0 deletions R/summaryPlots.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ makeMeanSDPlot <- function(sce, assayName, xlab = "Mean", ylab = "SD") {
#'
#' @returns A \code{cowplot} object
#'
#' @examples
#' sce <- readRDS(system.file("extdata", "mq_example", "1356_sce.rds",
#' package = "einprot"))
#' tres <- runTest(sce, comparisons = list(c("RBC_ctrl", "Adnp"),
#' c("RBC_ctrl", "Chd4BF")),
#' testType = "limma", assayForTests = "log2_LFQ.intensity",
#' assayImputation = "imputed_LFQ.intensity")
#' makeSAPlot(tres$tests)
#'
#' @export
#' @author Charlotte Soneson
#'
Expand Down
Binary file added inst/extdata/mq_example/1356_sce.rds
Binary file not shown.
19 changes: 19 additions & 0 deletions inst/scripts/generate_mq_sce.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
library(einprot)
sampleAnnot <- read.delim(system.file("extdata", "mq_example",
"1356_sampleAnnot.txt",
package = "einprot"))
out <- runMaxQuantAnalysis(
outputDir = "~/Desktop/1356_mq",
outputBaseName = "1356",
forceOverwrite = TRUE,
species = "mouse",
mqFile = system.file("extdata", "mq_example", "1356_proteinGroups.txt",
package = "einprot"),
mqParameterFile = system.file("extdata", "mq_example", "1356_mqpar.xml",
package = "einprot"),
iColPattern = "^LFQ.intensity.",
sampleAnnot = sampleAnnot,
ctrlGroup = "RBC_ctrl",
stringIdCol = NULL,
includeFeatureCollections = "complexes"
)
9 changes: 9 additions & 0 deletions man/doPCA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions man/makeAbundanceExport.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions man/makeAbundanceHeatmap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions man/makeSAPlot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions man/makeiSEEScript.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/plotDetectedInSamples.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/plotFractionDetectedPerSample.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions man/plotImputationDistribution.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions man/plotVolcano.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions man/prepareFeatureCollections.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions man/runTest.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a442a22

Please sign in to comment.