| Title: | End-to-End RNA-Seq Processing from FASTQ to Publication-Ready Plots |
|---|---|
| Description: | A streamlined toolkit for RNA-seq analysis covering FASTQ/BAM import, quality control, alignment, read counting, normalization, differential expression analysis, and publication-ready visualizations including onco plots, volcano plots, heatmaps, and PCA. Operates in minimal mode with CRAN-only dependencies or in full mode when Bioconductor packages are available. |
| Authors: | R. Heller [aut, cre] (ORCID: <https://orcid.org/0000-0001-8006-9742>), Hanno Witte [aut], Konrad Steinestel [aut] |
| Maintainer: | R. Heller <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-11-03 18:06:28 UTC |
| Source: | https://github.com/CTTIR/bambamR |
Wrapper for STAR, HISAT2, or minimap2 alignment tools. Checks that the selected aligner is available on the system PATH before running.
bb_align( fastq, genome_index, output_dir, aligner = c("STAR", "HISAT2", "minimap2"), threads = 4L, paired = FALSE, extra_args = NULL )bb_align( fastq, genome_index, output_dir, aligner = c("STAR", "HISAT2", "minimap2"), threads = 4L, paired = FALSE, extra_args = NULL )
fastq |
Character. Path(s) to FASTQ files. For paired-end, provide a character vector of length 2. |
genome_index |
Character. Path to genome index directory (STAR) or index prefix (HISAT2, minimap2). |
output_dir |
Character. New or empty output directory for BAM files. |
aligner |
Character. One of |
threads |
Integer. Number of threads. Default |
paired |
Logical. Paired-end mode. If |
extra_args |
Character or NULL. Additional arguments to pass to the
aligner, one argument per element (for example |
A list with components:
Path to the output BAM file
A data.frame with alignment statistics
The exact command that was executed
For HISAT2, the original FASTQ and index paths before temporary aliasing. Temporary aliases are removed after execution.
# Requires STAR/HISAT2/minimap2 installed # result <- bb_align("reads.fastq", "/path/to/index", "output/")# Requires STAR/HISAT2/minimap2 installed # result <- bb_align("reads.fastq", "/path/to/index", "output/")
Returns the total number of reads in a BAM file using Rsamtools or system samtools.
bb_count_bam(path)bb_count_bam(path)
path |
Character. Path to a BAM file. |
A numeric value: total number of reads.
# count <- bb_count_bam("aligned.bam")# count <- bb_count_bam("aligned.bam")
Counts reads overlapping genomic features. Uses
GenomicAlignments::summarizeOverlaps() if available, otherwise shells out
to featureCounts from the Subread package.
bb_count_reads( bam_paths, annotation, method = c("auto", "internal", "featureCounts"), threads = 4L, feature_type = "exon", attr_type = "gene_id", paired = FALSE )bb_count_reads( bam_paths, annotation, method = c("auto", "internal", "featureCounts"), threads = 4L, feature_type = "exon", attr_type = "gene_id", paired = FALSE )
bam_paths |
Character vector. Paths to BAM files. Optional vector names supply unique sample IDs when BAM basenames are not unique. |
annotation |
Character. Path to GTF/GFF annotation file. |
method |
Character. |
threads |
Integer. Number of threads for featureCounts. Default |
feature_type |
Character. Feature type to count (GTF column 3).
Default |
attr_type |
Character. Attribute to group by. Default |
paired |
Logical. Count paired-end fragments. Default |
A numeric matrix of counts (genes x samples). Rownames are gene IDs, colnames are derived from BAM file names.
# Requires BAM files and a GTF annotation # counts <- bb_count_reads(c("s1.bam", "s2.bam"), "genes.gtf")# Requires BAM files and a GTF annotation # counts <- bb_count_reads(c("s1.bam", "s2.bam"), "genes.gtf")
Runs DESeq2 differential expression analysis. Requires the DESeq2 package.
bb_deseq2(counts, coldata, design = ~condition, contrast = NULL, alpha = 0.05)bb_deseq2(counts, coldata, design = ~condition, contrast = NULL, alpha = 0.05)
counts |
Numeric matrix. Raw (unnormalized) count matrix. |
coldata |
A data.frame with sample information. Rownames must match
column names of |
design |
A formula specifying the design. Default |
contrast |
Character vector of length 3: |
alpha |
Numeric. FDR threshold for independent filtering.
Default |
A data.frame with columns gene, log2fc, pvalue, padj,
basemean.
if (requireNamespace("DESeq2", quietly = TRUE)) { counts <- matrix(rpois(600, 100), nrow = 100, ncol = 6, dimnames = list(paste0("gene", 1:100), paste0("S", 1:6))) coldata <- data.frame( condition = factor(rep(c("ctrl", "treat"), each = 3)), row.names = paste0("S", 1:6) ) result <- bb_deseq2(counts, coldata) head(result) }if (requireNamespace("DESeq2", quietly = TRUE)) { counts <- matrix(rpois(600, 100), nrow = 100, ncol = 6, dimnames = list(paste0("gene", 1:100), paste0("S", 1:6))) coldata <- data.frame( condition = factor(rep(c("ctrl", "treat"), each = 3)), row.names = paste0("S", 1:6) ) result <- bb_deseq2(counts, coldata) head(result) }
Runs edgeR quasi-likelihood differential expression analysis. Requires
the edgeR package.
bb_edger(counts, group, design = NULL)bb_edger(counts, group, design = NULL)
counts |
Numeric matrix. Raw count matrix. |
group |
Factor or character vector. Group assignment for each sample. |
design |
A design matrix. If |
A data.frame with columns gene, log2fc, pvalue, padj.
if (requireNamespace("edgeR", quietly = TRUE)) { counts <- matrix(rpois(600, 100), nrow = 100, ncol = 6, dimnames = list(paste0("gene", 1:100), paste0("S", 1:6))) group <- factor(rep(c("ctrl", "treat"), each = 3)) result <- bb_edger(counts, group) head(result) }if (requireNamespace("edgeR", quietly = TRUE)) { counts <- matrix(rpois(600, 100), nrow = 100, ncol = 6, dimnames = list(paste0("gene", 1:100), paste0("S", 1:6))) group <- factor(rep(c("ctrl", "treat"), each = 3)) result <- bb_edger(counts, group) head(result) }
Loads a synthetic RNA-seq count matrix (200 genes x 10 samples) with sample metadata. The first 20 genes have simulated differential expression between control and treatment groups.
bb_example_counts()bb_example_counts()
A list with components:
A 200 x 10 integer matrix of raw counts. Rownames are gene symbols, colnames are sample IDs.
A data.frame with columns condition, batch, sex,
age. Rownames match colnames of counts.
ex <- bb_example_counts() dim(ex$counts) head(ex$metadata) # Quick pipeline from example data cpm <- bb_normalize(ex$counts, method = "cpm") bb_pca(cpm, ex$metadata, color_by = "condition")ex <- bb_example_counts() dim(ex$counts) head(ex$metadata) # Quick pipeline from example data cpm <- bb_normalize(ex$counts, method = "cpm") bb_pca(cpm, ex$metadata, color_by = "condition")
Loads pre-computed differential expression results (500 genes) with realistic log2 fold-changes and p-values. The first 20 genes are simulated as significantly differentially expressed.
bb_example_de()bb_example_de()
A data.frame with columns gene, log2fc, pvalue, padj,
basemean.
de <- bb_example_de() head(de[order(de$padj), ]) # Volcano plot bb_volcano(de) # MA plot bb_ma_plot(de)de <- bb_example_de() head(de[order(de$padj), ]) # Volcano plot bb_volcano(de) # MA plot bb_ma_plot(de)
Loads synthetic mutation data (300 mutations across 50 samples and 20 cancer-related genes) suitable for oncoplot visualization, along with clinical annotation data.
bb_example_mutations()bb_example_mutations()
A list with components:
A data.frame with columns sample, gene,
mutation_type.
A data.frame with columns Stage, Gender, Smoking.
Rownames are sample IDs.
ex <- bb_example_mutations() head(ex$mutations) # Basic oncoplot bb_oncoplot(ex$mutations, n_genes = 10) # With clinical annotations bb_oncoplot(ex$mutations, n_genes = 10, annotation_df = ex$clinical)ex <- bb_example_mutations() head(ex$mutations) # Basic oncoplot bb_oncoplot(ex$mutations, n_genes = 10) # With clinical annotations bb_oncoplot(ex$mutations, n_genes = 10, annotation_df = ex$clinical)
Writes a differential expression result data.frame to a CSV file.
bb_export_csv(de_result, path)bb_export_csv(de_result, path)
de_result |
A data.frame with DE results (columns: gene, log2fc, pvalue, padj, and optionally basemean). |
path |
Character. File path for the output |
The path invisibly.
de <- data.frame( gene = paste0("gene", 1:5), log2fc = rnorm(5), pvalue = runif(5, 0, 0.1), padj = runif(5, 0, 0.1) ) tmp <- tempfile(fileext = ".csv") bb_export_csv(de, tmp)de <- data.frame( gene = paste0("gene", 1:5), log2fc = rnorm(5), pvalue = runif(5, 0, 0.1), padj = runif(5, 0, 0.1) ) tmp <- tempfile(fileext = ".csv") bb_export_csv(de, tmp)
Saves a bambamR result object or any R object as an RDS file.
bb_export_rds(result, path)bb_export_rds(result, path)
result |
An R object to save (typically a |
path |
Character. File path for the output |
The path invisibly.
tmp <- tempfile(fileext = ".rds") counts <- matrix(rpois(100, 50), nrow = 10, dimnames = list(paste0("g", 1:10), paste0("s", 1:10))) bb_export_rds(counts, tmp) readRDS(tmp)tmp <- tempfile(fileext = ".rds") counts <- matrix(rpois(100, 50), nrow = 10, dimnames = list(paste0("g", 1:10), paste0("s", 1:10))) bb_export_rds(counts, tmp) readRDS(tmp)
Writes a differential expression result data.frame to a TSV file.
bb_export_tsv(de_result, path)bb_export_tsv(de_result, path)
de_result |
A data.frame with DE results. |
path |
Character. File path for the output |
The path invisibly.
de <- data.frame( gene = paste0("gene", 1:5), log2fc = rnorm(5), pvalue = runif(5, 0, 0.1), padj = runif(5, 0, 0.1) ) tmp <- tempfile(fileext = ".tsv") bb_export_tsv(de, tmp)de <- data.frame( gene = paste0("gene", 1:5), log2fc = rnorm(5), pvalue = runif(5, 0, 0.1), padj = runif(5, 0, 0.1) ) tmp <- tempfile(fileext = ".tsv") bb_export_tsv(de, tmp)
Creates a heatmap from a normalized count matrix, optionally highlighting the top DE genes.
bb_heatmap( counts, de_result = NULL, n_genes = 50L, annotation_col = NULL, scale = c("row", "column", "none"), cluster_rows = TRUE, cluster_cols = TRUE, color_palette = NULL )bb_heatmap( counts, de_result = NULL, n_genes = 50L, annotation_col = NULL, scale = c("row", "column", "none"), cluster_rows = TRUE, cluster_cols = TRUE, color_palette = NULL )
counts |
Numeric matrix. Normalized count matrix (genes x samples). |
de_result |
A data.frame with DE results. If provided, the top
|
n_genes |
Integer. Number of top genes to display. Default |
annotation_col |
A data.frame for column (sample) annotations.
Rownames must match column names of |
scale |
Character. Scale rows ( |
cluster_rows |
Logical. Cluster rows. Default |
cluster_cols |
Logical. Cluster columns. Default |
color_palette |
Character vector. Colors for the heatmap gradient. |
A ggplot2::ggplot object.
set.seed(42) counts <- matrix(rpois(500, 100), nrow = 50, ncol = 10, dimnames = list(paste0("gene", 1:50), paste0("S", 1:10))) bb_heatmap(counts, n_genes = 20)set.seed(42) counts <- matrix(rpois(500, 100), nrow = 50, ncol = 10, dimnames = list(paste0("gene", 1:50), paste0("S", 1:10))) bb_heatmap(counts, n_genes = 20)
Runs limma-voom differential expression analysis. Requires the limma
and edgeR packages.
bb_limma_voom(counts, design, contrast = NULL)bb_limma_voom(counts, design, contrast = NULL)
counts |
Numeric matrix. Raw count matrix. |
design |
A design matrix (e.g., from |
contrast |
A contrast vector or one-column matrix. If |
A data.frame with columns gene, log2fc, pvalue, padj.
if (requireNamespace("limma", quietly = TRUE) && requireNamespace("edgeR", quietly = TRUE)) { counts <- matrix(rpois(600, 100), nrow = 100, ncol = 6, dimnames = list(paste0("gene", 1:100), paste0("S", 1:6))) group <- factor(rep(c("ctrl", "treat"), each = 3)) design <- model.matrix(~ group) result <- bb_limma_voom(counts, design) head(result) }if (requireNamespace("limma", quietly = TRUE) && requireNamespace("edgeR", quietly = TRUE)) { counts <- matrix(rpois(600, 100), nrow = 100, ncol = 6, dimnames = list(paste0("gene", 1:100), paste0("S", 1:6))) group <- factor(rep(c("ctrl", "treat"), each = 3)) design <- model.matrix(~ group) result <- bb_limma_voom(counts, design) head(result) }
Creates an MA plot (log2 fold-change vs. mean expression) from differential expression results.
bb_ma_plot( de_result, p_cutoff = 0.05, point_size = 1, colors = c(sig = "#D73027", ns = "grey70") )bb_ma_plot( de_result, p_cutoff = 0.05, point_size = 1, colors = c(sig = "#D73027", ns = "grey70") )
de_result |
A data.frame with columns |
p_cutoff |
Numeric. Adjusted p-value cutoff for coloring significant
genes. Default |
point_size |
Numeric. Size of points. Default |
colors |
Named character vector with |
A ggplot2::ggplot object.
de <- data.frame( gene = paste0("gene", 1:200), log2fc = rnorm(200, 0, 2), pvalue = 10^(-runif(200, 0, 5)), padj = 10^(-runif(200, 0, 4)), basemean = 10^runif(200, 1, 4) ) bb_ma_plot(de)de <- data.frame( gene = paste0("gene", 1:200), log2fc = rnorm(200, 0, 2), pvalue = 10^(-runif(200, 0, 5)), padj = 10^(-runif(200, 0, 4)), basemean = 10^runif(200, 1, 4) ) bb_ma_plot(de)
Supports CPM, TPM, TMM (edgeR), and RLE (DESeq2) normalization. CPM and TPM are always available. TMM requires edgeR, RLE requires DESeq2.
bb_normalize( counts, method = c("cpm", "tpm", "tmm", "rle"), gene_lengths = NULL )bb_normalize( counts, method = c("cpm", "tpm", "tmm", "rle"), gene_lengths = NULL )
counts |
Numeric matrix. Raw count matrix with gene IDs as rownames and sample names as colnames. |
method |
Character. One of |
gene_lengths |
Numeric vector. Gene lengths in base pairs. Required
for TPM normalization. Must be named or in the same order as rownames
of |
CPM (Counts Per Million): counts / library_size * 1e6. Pure base R.
TPM (Transcripts Per Million): Normalizes by gene length then library
size. Pure base R but requires gene_lengths.
TMM (Trimmed Mean of M-values): Uses edgeR::calcNormFactors().
Requires the edgeR package.
RLE (Relative Log Expression): Uses DESeq2::estimateSizeFactors().
Requires the DESeq2 package.
A normalized numeric matrix with the same dimensions as counts.
counts <- matrix( rpois(600, lambda = 100), nrow = 100, ncol = 6, dimnames = list(paste0("gene", 1:100), paste0("sample", 1:6)) ) cpm <- bb_normalize(counts, method = "cpm") head(cpm) # TPM requires gene lengths gene_lengths <- sample(500:5000, 100) tpm <- bb_normalize(counts, method = "tpm", gene_lengths = gene_lengths)counts <- matrix( rpois(600, lambda = 100), nrow = 100, ncol = 6, dimnames = list(paste0("gene", 1:100), paste0("sample", 1:6)) ) cpm <- bb_normalize(counts, method = "cpm") head(cpm) # TPM requires gene lengths gene_lengths <- sample(500:5000, 100) tpm <- bb_normalize(counts, method = "tpm", gene_lengths = gene_lengths)
Generates a waterfall-style oncoplot showing the mutation landscape
across samples. Accepts either a simple data.frame with sample,
gene, mutation_type columns or a MAF-format data.frame.
bb_oncoplot( data, genes = NULL, n_genes = 20L, sort_by = c("frequency", "cluster"), annotation_df = NULL, mutation_colors = NULL, show_pct = TRUE, show_barplot = TRUE, title = NULL, border_color = "white" )bb_oncoplot( data, genes = NULL, n_genes = 20L, sort_by = c("frequency", "cluster"), annotation_df = NULL, mutation_colors = NULL, show_pct = TRUE, show_barplot = TRUE, title = NULL, border_color = "white" )
data |
A data.frame with columns |
genes |
Character vector. Specific genes to display. If |
n_genes |
Integer. Number of top mutated genes if |
sort_by |
Character. How to sort samples: |
annotation_df |
A data.frame for sample annotations (bottom tracks).
Rownames must be sample identifiers. Each column becomes an annotation
track. Annotation tracks require |
mutation_colors |
Named character vector mapping mutation types to
colors. If |
show_pct |
Logical. Show mutation percentage per gene on the right
margin. Default |
show_barplot |
Logical. Show top (mutated genes per sample) and side
(mutated samples per gene) barplots. Default |
title |
Character or NULL. Plot title. |
border_color |
Character or NULL. Color of tile borders. Default
|
The oncoplot encodes the mutation landscape of a cohort as a tiled grid:
columns = samples, rows = genes. Tiles are colored by mutation type.
Multi-hit genes (multiple mutation types in one sample) are labeled
"Multi_Hit".
When show_barplot = TRUE and the patchwork package is available,
the plot is composed of three panels: top barplot (mutated genes per
sample), main tile plot, and right barplot (mutated samples per gene).
Without patchwork, the main tile plot is returned unless annotations were
requested. Percentages use all samples represented in data before gene
selection; samples with no recorded mutations cannot be inferred.
A ggplot2::ggplot object (composed with patchwork if barplots are shown and patchwork is available).
set.seed(42) mut_data <- data.frame( sample = sample(paste0("TCGA-", 1:30), 150, replace = TRUE), gene = sample(c("TP53","KRAS","PIK3CA","PTEN","APC", "BRAF","EGFR","NRAS","CDKN2A","RB1"), 150, replace = TRUE), mutation_type = sample(c("Missense_Mutation","Nonsense_Mutation", "Frame_Shift_Del","Splice_Site"), 150, replace = TRUE) ) bb_oncoplot(mut_data, n_genes = 10)set.seed(42) mut_data <- data.frame( sample = sample(paste0("TCGA-", 1:30), 150, replace = TRUE), gene = sample(c("TP53","KRAS","PIK3CA","PTEN","APC", "BRAF","EGFR","NRAS","CDKN2A","RB1"), 150, replace = TRUE), mutation_type = sample(c("Missense_Mutation","Nonsense_Mutation", "Frame_Shift_Del","Splice_Site"), 150, replace = TRUE) ) bb_oncoplot(mut_data, n_genes = 10)
Creates a PCA plot from a normalized count matrix with sample metadata.
bb_pca( counts, metadata, color_by, shape_by = NULL, n_genes = 500L, label = FALSE, point_size = 3 )bb_pca( counts, metadata, color_by, shape_by = NULL, n_genes = 500L, label = FALSE, point_size = 3 )
counts |
Numeric matrix. Normalized count matrix (genes x samples). |
metadata |
A data.frame with sample information. Rownames must match
column names of |
color_by |
Character. Column name in |
shape_by |
Character or NULL. Column name in |
n_genes |
Integer. Number of top variable genes to use for PCA.
Default |
label |
Logical. Whether to label sample points. Default |
point_size |
Numeric. Size of points. Default |
A ggplot2::ggplot object.
set.seed(42) counts <- matrix(rpois(600, 100), nrow = 100, ncol = 6, dimnames = list(paste0("gene", 1:100), paste0("S", 1:6))) meta <- data.frame( condition = rep(c("Control", "Treatment"), each = 3), row.names = paste0("S", 1:6) ) bb_pca(counts, meta, color_by = "condition")set.seed(42) counts <- matrix(rpois(600, 100), nrow = 100, ncol = 6, dimnames = list(paste0("gene", 1:100), paste0("S", 1:6))) meta <- data.frame( condition = rep(c("Control", "Treatment"), each = 3), row.names = paste0("S", 1:6) ) bb_pca(counts, meta, color_by = "condition")
Orchestrates the complete RNA-seq analysis pipeline from FASTQ/BAM files or a count matrix through alignment, counting, normalization, differential expression, and visualization.
bb_pipeline( fastq_dir = NULL, bam_dir = NULL, count_matrix = NULL, output_dir = "bambamR_output", genome_index = NULL, annotation = NULL, sample_info = NULL, aligner = "STAR", de_method = c("DESeq2", "edgeR", "limma"), design = ~condition, skip = character(0), threads = 4L )bb_pipeline( fastq_dir = NULL, bam_dir = NULL, count_matrix = NULL, output_dir = "bambamR_output", genome_index = NULL, annotation = NULL, sample_info = NULL, aligner = "STAR", de_method = c("DESeq2", "edgeR", "limma"), design = ~condition, skip = character(0), threads = 4L )
fastq_dir |
Character or NULL. Directory containing FASTQ files.
If provided, the pipeline starts from alignment. Each file is one
single-end sample, named by removing its FASTQ extension. For paired-end
reads use |
bam_dir |
Character or NULL. Directory containing BAM files. If provided, the pipeline starts from read counting. |
count_matrix |
A numeric matrix or NULL. Pre-computed count matrix. If provided, the pipeline starts from normalization/DE. |
output_dir |
Character. Output directory for results.
Default |
genome_index |
Character or NULL. Path to genome index. Required if starting from FASTQ. |
annotation |
Character or NULL. Path to GTF annotation. Required if starting from FASTQ or BAM. |
sample_info |
A data.frame with sample metadata. Must contain a
|
aligner |
Character. Aligner for FASTQ alignment. Default |
de_method |
Character. DE method: |
design |
A formula for DE analysis. Default |
skip |
Character vector. Steps to skip: |
threads |
Integer. Number of threads. Default |
The pipeline allows entry at any stage:
From FASTQ: requires fastq_dir, genome_index, annotation,
and sample_info
From BAM: requires bam_dir, annotation, and sample_info
From counts: requires count_matrix and sample_info
A bb_result object containing counts, metadata, DE results,
and plots.
# Starting from a count matrix (minimal mode, no Bioconductor needed) set.seed(42) counts <- matrix(rpois(600, 100), nrow = 100, ncol = 6, dimnames = list(paste0("gene", 1:100), paste0("S", 1:6))) sample_info <- data.frame( condition = factor(rep(c("ctrl", "treat"), each = 3)), row.names = paste0("S", 1:6) ) # result <- bb_pipeline(count_matrix = counts, sample_info = sample_info)# Starting from a count matrix (minimal mode, no Bioconductor needed) set.seed(42) counts <- matrix(rpois(600, 100), nrow = 100, ncol = 6, dimnames = list(paste0("gene", 1:100), paste0("S", 1:6))) sample_info <- data.frame( condition = factor(rep(c("ctrl", "treat"), each = 3)), row.names = paste0("S", 1:6) ) # result <- bb_pipeline(count_matrix = counts, sample_info = sample_info)
Creates a panel of QC plots from a bb_qc object, including read quality
per position, GC content distribution, and read length distribution.
bb_plot_qc(qc_object, which = c("all", "quality", "gc", "length"))bb_plot_qc(qc_object, which = c("all", "quality", "gc", "length"))
qc_object |
A |
which |
Character. Which plot to generate: |
A ggplot2::ggplot object (or a patchwork composition if
which = "all" and patchwork is available).
tmp <- tempfile(fileext = ".fastq") writeLines(c( "@r1", "ACGTACGT", "+", "IIIIIIII", "@r2", "GCGCGCGC", "+", "HHHHHHHH", "@r3", "ATATGCGC", "+", "GGGGFFFF" ), tmp) qc <- bb_qc(fastq_path = tmp) bb_plot_qc(qc)tmp <- tempfile(fileext = ".fastq") writeLines(c( "@r1", "ACGTACGT", "+", "IIIIIIII", "@r2", "GCGCGCGC", "+", "HHHHHHHH", "@r3", "ATATGCGC", "+", "GGGGFFFF" ), tmp) qc <- bb_qc(fastq_path = tmp) bb_plot_qc(qc)
Computes quality control metrics from FASTQ and/or BAM files.
bb_qc(fastq_path = NULL, bam_path = NULL, use_fastqc = TRUE)bb_qc(fastq_path = NULL, bam_path = NULL, use_fastqc = TRUE)
fastq_path |
Character or NULL. Path(s) to FASTQ file(s). |
bam_path |
Character or NULL. Path(s) to BAM file(s). |
use_fastqc |
Logical. Try to use system FastQC if available.
Default |
A bb_qc object containing:
Total reads per file
Per-position quality score summary
GC content distribution
Read length distribution
Mapping rate from BAM files (if provided)
# Create a test FASTQ tmp <- tempfile(fileext = ".fastq") writeLines(c( "@read1", "ACGTACGT", "+", "IIIIIIII", "@read2", "GCGCGCGC", "+", "HHHHHHHH" ), tmp) qc <- bb_qc(fastq_path = tmp) qc# Create a test FASTQ tmp <- tempfile(fileext = ".fastq") writeLines(c( "@read1", "ACGTACGT", "+", "IIIIIIII", "@read2", "GCGCGCGC", "+", "HHHHHHHH" ), tmp) qc <- bb_qc(fastq_path = tmp) qc
Returns a summary data.frame of QC metrics.
bb_qc_summary(qc_object)bb_qc_summary(qc_object)
qc_object |
A |
A data.frame with one row per file.
tmp <- tempfile(fileext = ".fastq") writeLines(c("@r1", "ACGT", "+", "IIII"), tmp) qc <- bb_qc(fastq_path = tmp) bb_qc_summary(qc)tmp <- tempfile(fileext = ".fastq") writeLines(c("@r1", "ACGT", "+", "IIII"), tmp) qc <- bb_qc(fastq_path = tmp) bb_qc_summary(qc)
Reads BAM files using Rsamtools (if available) or the system samtools
command as fallback.
bb_read_bam( path, index = TRUE, what = c("qname", "flag", "rname", "pos", "mapq", "cigar") )bb_read_bam( path, index = TRUE, what = c("qname", "flag", "rname", "pos", "mapq", "cigar") )
path |
Character. Path to a BAM file. |
index |
Logical. Whether to use/create a BAM index. Default |
what |
Character vector. Fields to extract. Default includes basic alignment fields. |
A data.frame with alignment information including columns:
qname, flag, rname, pos, mapq, cigar.
# Requires a BAM file # bam_df <- bb_read_bam("aligned.bam")# Requires a BAM file # bam_df <- bb_read_bam("aligned.bam")
Reads FASTQ files using ShortRead (if available) or a minimal
base-R parser as fallback. Supports .gz compressed files.
bb_read_fastq(path, n = NULL)bb_read_fastq(path, n = NULL)
path |
Character. Path to a FASTQ or FASTQ.gz file. |
n |
Integer or NULL. Number of initial reads to read. |
A data.frame with columns:
Read identifier
Nucleotide sequence
Quality string (Phred+33 encoded)
# Create a temporary FASTQ file tmp <- tempfile(fileext = ".fastq") writeLines(c( "@read1", "ACGTACGT", "+", "IIIIIIII", "@read2", "TGCATGCA", "+", "HHHHHHHH" ), tmp) reads <- bb_read_fastq(tmp) reads# Create a temporary FASTQ file tmp <- tempfile(fileext = ".fastq") writeLines(c( "@read1", "ACGTACGT", "+", "IIIIIIII", "@read2", "TGCATGCA", "+", "HHHHHHHH" ), tmp) reads <- bb_read_fastq(tmp) reads
Starts the interactive bambamR Shiny application for RNA-seq analysis.
Requires the shiny package.
bb_run_app(...)bb_run_app(...)
... |
Additional arguments passed to |
This function does not return a value; it launches a Shiny app.
if (interactive() && requireNamespace("shiny", quietly = TRUE)) { bb_run_app() }if (interactive() && requireNamespace("shiny", quietly = TRUE)) { bb_run_app() }
Creates a publication-ready volcano plot from differential expression results.
bb_volcano( de_result, fc_cutoff = 1, p_cutoff = 0.05, label_genes = NULL, n_label = 10L, point_size = 1, colors = c(up = "#D73027", down = "#4575B4", ns = "grey70") )bb_volcano( de_result, fc_cutoff = 1, p_cutoff = 0.05, label_genes = NULL, n_label = 10L, point_size = 1, colors = c(up = "#D73027", down = "#4575B4", ns = "grey70") )
de_result |
A data.frame with columns |
fc_cutoff |
Numeric. Absolute log2 fold-change cutoff for significance.
Default |
p_cutoff |
Numeric. Adjusted p-value cutoff for significance.
Default |
label_genes |
Character vector. Specific gene names to label on the
plot. If |
n_label |
Integer. Number of top significant genes to auto-label
when |
point_size |
Numeric. Size of points. Default |
colors |
Named character vector of length 3 for up, down, and non-significant colors. |
A ggplot2::ggplot object.
de <- data.frame( gene = paste0("gene", 1:200), log2fc = rnorm(200, 0, 2), pvalue = 10^(-runif(200, 0, 5)), padj = 10^(-runif(200, 0, 4)) ) bb_volcano(de)de <- data.frame( gene = paste0("gene", 1:200), log2fc = rnorm(200, 0, 2), pvalue = 10^(-runif(200, 0, 5)), padj = 10^(-runif(200, 0, 4)) ) bb_volcano(de)
Print method for bb_qc
## S3 method for class 'bb_qc' print(x, ...)## S3 method for class 'bb_qc' print(x, ...)
x |
A bb_qc object. |
... |
Additional arguments (ignored). |
Print method for bb_result
## S3 method for class 'bb_result' print(x, ...)## S3 method for class 'bb_result' print(x, ...)
x |
A bb_result object. |
... |
Additional arguments (ignored). |
Summary method for bb_qc
## S3 method for class 'bb_qc' summary(object, ...)## S3 method for class 'bb_qc' summary(object, ...)
object |
A bb_qc object. |
... |
Additional arguments (ignored). |