collect_counts: Collect the count files of several samples into a single data...

Description Usage Arguments Value Examples

View source: R/collect-counts.R

Description

This function takes a directory path dir_path and searches that directory for files whose names end in '_counts.txt'. It reads those files and concatenates them. Each file is assumed to correspond to a single sample whose name is contained in the first part of the file name (the bit before '_counts.txt'). These sample names are used as column names in the output data frame.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
collect_counts(
  dir_path,
  convert_genenames = TRUE,
  cpm = FALSE,
  log2 = FALSE,
  remove_ercc = TRUE,
  remove_rp_4_11 = TRUE,
  remove_metadata = TRUE,
  remove_controls = TRUE,
  write = FALSE
)

Arguments

dir_path

A character vector. The path to the directory containing '*_counts.txt' files. To specify several directories, use a list of paths.

convert_genenames

A flag. Convert gene names from Ensembl IDs to more widely-used names?

cpm

A flag. Convert raw counts to counts-per-million (on a per sample basis)?

log2

A flag. Transform the counts using log2(x + 1)?

remove_ercc

A flag. Remove ERCC counts from the results?

remove_rp_4_11

A flag. RP4 and RP11 genes come from a particular donor when building the genome and are mostly not useful. The default (TRUE) is to remove them.

remove_metadata

A flag. The count files can contain non-gene metadata (e.g. mapping stats). The default (TRUE) is to remove them.

remove_controls

A flag. The count files can contain positive and negative controls (denoted by having names ending in 'PC_counts.txt' or 'NC_counts.txt'). The default (TRUE) is to remove them.

write

A flag or string. Write the results to disk as a tab-separated file? If TRUE, the file will be written to the working directory with name 'genes_counts.txt', 'genes_cpm.txt', genes_log2.txt' or 'genes_log2_cpm.txt'. To write the file elsewhere, pass the path through this argument as a string.

Value

A data frame object.

Examples

1
2
3
4
## Not run: 
collect_counts("path/to/dir/with/count/files")

## End(Not run)

mirvie/mirmisc documentation built on Dec. 21, 2021, 7 p.m.