Longo-Lab / de_dashboards

https://longo-lab.github.io/de_dashboards/
0 stars 0 forks source link

DE dashboards

This provides instructions on how to generate the DE (and stimulation) dashboards using 2 methods:

Shiny version

Run the following scripts in the project directory to save the dashboard files:

                          biodomain_correlation.R biodomain_enrichment.R save_dashboard_files.R save_stim_dashboard_files.R
-n
--nameset
Name of project Name of project Name of project Name of project
-g
--genotype
Name of genotype Name of genotype Name of genotype Name of genotype
-d
--drug
Name of drug Name of drug Name of drug Name of drug
-r
--round-number
Round of source file

default: R1
Round of source file

default: R1
Round of source file

default: R1
Round of source file

default: R1
-t
--type
Cell type if single-cell data, otherwise bulk for bulk data or stim for stimulation analysis

default: bulk
Cell type if single-cell data, otherwise bulk for bulk data or stim for stimulation analysis

default: bulk
Cell type if single-cell data, otherwise bulk for bulk data

default: bulk
--
-a
--analyses
Name of comparisons (ORDER BY geno, drug, geno + drug OR stim in wtv, tgv, tgd)

If -t is NOT stim, default: Tg-VvsWt-V,Tg-DvsTg-V,Tg-DvsWt-V

If -t is stim, default: Wt-StvsWt-Un,Tg-StvsTg-Un,Tg-D-StvsTg-D-Un
Name of comparisons (ORDER BY geno, drug, geno + drug OR stim in wtv, tgv, tgd)

If -t is NOT stim, default: Tg-VvsWt-V,Tg-DvsTg-V,Tg-DvsWt-V

If -t is stim, default: Wt-StvsWt-Un,Tg-StvsTg-Un,Tg-D-StvsTg-D-Un
Name of comparisons (ORDER BY geno, drug, geno + drug)

default: Tg-VvsWt-V,Tg-DvsTg-V,Tg-DvsWt-V
Name of comparisons (ORDER BY stim in wtv, tgv, tgd)

default: Wt-StvsWt-Un,Tg-StvsTg-Un,Tg-D-StvsTg-D-Un
-s
--shrunken
Flag indicating shrunken LFC is being used

default: FALSE

Note: This is more for consistency w/ the other scripts and to use default -c value of shrunkenL2FC. If providing custom shrunken LFC column name, including -s or not technically does not make a difference.
Flag indicating shrunken LFC is being used

default: FALSE
Flag indicating shrunken LFC is being used

default: FALSE
Flag indicating shrunken LFC is being used

default: FALSE
-u
--unadjusted-p
-- Flag indicating unadjusted (nominal) p-value is being used for filtering instead of adjusted p-value (in the case of unshrunken LFC)

default: FALSE

_Note: This is more for consistency w/ save_dashboard_files.R and to use default -c value for p-value filter. If providing custom p-value column name, including -u or not technically does not make a difference._
Flag indicating unadjusted (nominal) p-value is being used for filtering instead of adjusted p-value (in the case of unshrunken LFC)

default: FALSE
--
-i
--gene-col
Column name for gene ID (bulk) or symbol (single-cell)

default: GENE
Column name for gene ID (bulk) or symbol (single-cell)

default: GENE
Column name for gene ID (bulk) or symbol (single-cell)

default: GENE
Column name for gene ID

default: GENE
-c
--de-columns
Column name for log fold change (can provide shrunken or unshrunken)

If -s, default: shrunkenL2FC

If -t is bulk/stim, default: log2FoldChange

If -t is single-cell, default: avg_log2FC
If shrunken (and not stim), column name for shrunken log fold change OR if unshrunken (or stim), column names for log fold change and p-value column for filtering

If -s and -t is NOT stim, default: shrunkenL2FC

If -s and -t is stim, default: shrunkenL2FC,padj

If -t is bulk/stim, default: log2FoldChange,padj OR log2FoldChange,pvalue if -u

If -t is single-cell, default: avg_log2FC,p_val_adj OR avg_log2FC,p_val if -u

Note: Must use padj < 0.05 threshold w/ either shrunken or unshrunken LFC for stim dashboard.
If shrunken, column names in the order of sLFC,sval,LFC,pval,padj OR if unshrunken, column names in the order of LFC,p1,p2,(pct1,pct2), where p1 is the same p-value column used for filtering in biodomain_enrichment.R, p2 is the other (out of p-value and p-adj columns), and pct1/pct2 only applies for single-cell data

If -s, default: shrunkenL2FC,svalue,log2FoldChange,pvalue,padj

If -t is bulk/stim, default: log2FoldChange,padj,pvalue OR log2FoldChange,pvalue,padj if -u

If -t is single-cell, default: avg_log2FC,p_val_adj,p_val,pct.1,pct.2 OR avg_log2FC,p_val,p_val_adj,pct.1,pct.2 if -u
If shrunken, column names in the order of sLFC,padj,sval,LFC,pval OR if unshrunken, column names in the order of LFC,adj,pval

If -s, default: shrunkenL2FC,padj,svalue,log2FoldChange,pvalue

If NOT -s, default: log2FoldChange,padj,pvalue
-l
--lfc-threshold
-- LFC threshold used to filter genes

default: log2(1.1)
LFC threshold used to filter genes

default: log2(1.1)
LFC threshold used to filter genes

default: log2(1.1)
-p
--p-threshold
-- P-value threshold used to filter genes

default: 0.05

Note: Do not change default for stim dashboard.
P-value threshold used to filter genes

default: 0.05
--

Note: ensembl_ver and gProfiler term_size_limit are defined at the top of the scripts. The Ensembl genes data is saved inside reference/biodomains/ by the genes_info.R script located there.

Deploying to shinyapps.io

In the project directory, add a copy of app.R or app_stim.R (must be renamed to app.R if deploying) and www/.

Inside app.R, define the following variables at the top of the file:

Also, modify the following sections accordingly:

In www/style.css, uncomment the appropriate sections as indicated within the file:

See deploy.R for template of deploying to shinyapps.io. Make sure to add this file to .gitignore if using as it contains credential information.

If running into error regarding package version while deploying, see here to downgrade package version.

If published dashboard is having trouble loading, you may need to increase the instance size from the shinyapps.io dashboard: Settings > General > Instance Size

flexdashboard version

Use rmarkdown::render() to knit the dashboard.Rmd template with the following options:

Note: Required options are in bold.

Troubleshooting

Load R and run script to generate dashboards:

$ ml R/4.0
$ Rscript scripts/PS19_C31.R

Ensure tidyr is updated to at least v.1.2.0 to use the names_vary argument for pivot_wider():

$ R
> install.packages('tidyr')

If running into ReferenceError: FlexDashboard is not defined, make sure pandoc is up-to-date. This can be done by specifying the RSTUDIO_PANDOC environment variable in ~/.bash_profile:

export RSTUDIO_PANDOC=/usr/lib/rstudio-server/bin/quarto/bin

To encrypt the HTML files using staticrypt, install the CLI locally with npm:

$ mkdir -p .npm/node_modules
$ npm install --prefix .npm/ staticrypt

Make sure to append to the PATH environment variable in ~/.bash_profile:

PATH=$PATH:$HOME/.npm/node_modules/.bin
export PATH

Encrypt all HTML files in the output directory, making sure to purge modules if there are conflicts:

$ module purge
$ find outputs/PS19_C31/ -type f -name "*.html" -exec staticrypt {} PASSPHRASE -o {} -r 1 \;

Alternatively, run gen_dashboards.sh and provide the name (-n) and password (-p) arguments:

$ sbatch gen_dashboards.sh -n PS19_C31 -p PASSPHRASE

Use

This repository is for internal use of the Longo Lab only. All work herein is under the exclusive copyright of the Longo Lab. Open source versions of the code may be made available in dedicated repositories associated with individual publications and projects at the discretion of the Longo Lab.