generate_bootstrap_plots: Generate bootstrap plots

Description Usage Arguments Value Examples

View source: R/generate_bootstrap_plots.r

Description

generate_bootstrap_plots takes a genelist and a single cell type transcriptome dataset and generates plots which show how the expression of the genes in the list compares to those in randomly generated gene lists

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
generate_bootstrap_plots(
  sct_data,
  hits,
  bg,
  genelistSpecies = "mouse",
  sctSpecies = "mouse",
  reps,
  annotLevel = 1,
  full_results = NA,
  listFileName = "",
  savePath = tempdir()
)

Arguments

sct_data

List generated using generate_celltype_data

hits

Array of MGI/HGNC gene symbols containing the target gene list.

bg

Array of MGI/HGNC gene symbols containing the background gene list.

genelistSpecies

Either 'mouse' or 'human' depending on whether MGI or HGNC symbols are used for gene lists

sctSpecies

Either 'mouse' or 'human' depending on whether MGI or HGNC symbols are used for the single cell dataset

reps

Number of random gene lists to generate (default=100 but should be over 10000 for publication quality results)

annotLevel

an integer indicating which level of the annotation to analyse. Default = 1.

full_results

The full output of bootstrap_enrichment_test for the same genelist

listFileName

String used as the root for files saved using this function

savePath

Directory where the BootstrapPlots folder should be saved, default is a temp directory

Value

Saves a set of pdf files containing graphs and returns the file where they are saved. These will be saved with the filename adjusted using the value of listFileName. The files are saved into the 'BootstrapPlot' folder. Files start with one of the following:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
library(ewceData)
# Load the single cell data
ctd <- ctd()

# Set the parameters for the analysis
# Use 5 bootstrap lists for speed, for publishable analysis use >10000
reps <- 5

# Load the gene list and get human orthologs
example_genelist <- example_genelist()
mouse_to_human_homologs <- mouse_to_human_homologs()
m2h <- unique(mouse_to_human_homologs[, c("HGNC.symbol", "MGI.symbol")])
mouse.hits <-
    unique(m2h[m2h$HGNC.symbol %in% example_genelist, "MGI.symbol"])
#subset mouse.bg for speed but ensure it still contains the hits
mouse.bg <- unique(c(m2h$MGI.symbol[1:100],mouse.hits))

# Bootstrap significance test, no control for transcript length or GC content
full_results <- bootstrap_enrichment_test(
    sct_data = ctd, hits = mouse.hits,
    bg = mouse.bg, reps = reps, annotLevel = 1, sctSpecies = "mouse",
    genelistSpecies = "mouse"
)

plot_file_pth <- generate_bootstrap_plots(
    sct_data = ctd, hits = mouse.hits, bg = mouse.bg,
    reps = reps, full_results = full_results, listFileName = "Example",
    genelistSpecies = "mouse", sctSpecies = "mouse", annotLevel = 1,
    savePath=tempdir()
)

NathanSkene/EWCE documentation built on June 19, 2021, 5:40 a.m.