-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from CCBR/iss-2
Create filter_low_counts()
- Loading branch information
Showing
19 changed files
with
59,124 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,6 @@ | |
^\.github$ | ||
^README\.Rmd$ | ||
^\.pre-commit-config\.yaml$ | ||
^\.prettierignore$ | ||
^\.prettierrc$ | ||
^data-raw$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# gitignore | ||
.nextflow* | ||
work/ | ||
data/ | ||
results/ | ||
.DS_Store | ||
*.code-workspace | ||
assets/*.html | ||
data-raw/*.txt | ||
man/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
overrides: | ||
- files: "*.md" | ||
options: | ||
tabWidth: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export("%>%") | ||
export(filter_low_counts) | ||
export(read_raw_counts) | ||
importFrom(dplyr,"%>%") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# reneeTools development version | ||
# reneeTools 0.1.0 | ||
|
||
- Create a `NEWS.md` file to track changes to the package. | ||
|
||
# reneeTools 0.1.0 | ||
## New functions | ||
|
||
- `filter_low_counts()` (#10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#' RSEM gene counts | ||
#' | ||
#' @format ## `gene_counts` | ||
#' A data frame with columns 'gene_id', 'GeneName', and a column for each sample's count. | ||
#' | ||
#' @source Generated by running RENEE v2.5.8 on the | ||
#' [test dataset](https://github.com/CCBR/RENEE/tree/e08f7db6c6e638cfd330caa182f64665d2ef37fa/.tests) | ||
"gene_counts" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
#' filter_low_counts | ||
#' | ||
#' @param raw_counts_matrix raw_counts_matrix object | ||
#' @param min_counts integer number of min_counts across all samples, default 0 | ||
#' @param min_cpm float minimum cpm value, default 0 | ||
#' @param min_cpm_fraction float fraction of samples that need to satisfy min_cpm filter, default 1.0 | ||
#' @param counts_dat dataframe of expected gene counts from RSEM | ||
#' @param min_counts integer number of minimum counts across all samples (default: 0) | ||
#' | ||
#' @return filtered_raw_count_matrix | ||
#' @return filtered counts dataframe | ||
#' @export | ||
#' | ||
#' @examples | ||
#' filter_low_counts(gene_counts) %>% head() | ||
#' filter_low_counts(gene_counts, min_counts = 100) | ||
filter_low_counts <- function( | ||
raw_counts_matrix, | ||
min_counts = 0, | ||
min_cpm = 0, | ||
min_cpm_fraction = 1.0) { | ||
|
||
counts_dat, | ||
min_counts = 0) { | ||
gene_id <- count <- count_sum <- NULL | ||
genes_above_threshold <- counts_dat %>% | ||
tidyr::pivot_longer(!c("gene_id", "GeneName"), | ||
names_to = "sample_id", values_to = "count" | ||
) %>% | ||
dplyr::group_by(gene_id) %>% | ||
dplyr::summarize(count_sum = sum(count)) %>% | ||
dplyr::filter(count_sum >= min_counts) %>% | ||
dplyr::pull(gene_id) | ||
return( | ||
counts_dat %>% | ||
dplyr::filter(gene_id %in% (genes_above_threshold)) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#' dplyr pipe | ||
#' @importFrom dplyr %>% | ||
#' @export | ||
dplyr::`%>%` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#' reneeTools: R helper functions for RENEE | ||
#' | ||
#' `reneeTools` implements helper functions for RENEE, a comprehensive | ||
#' quality-control and quantification RNA-seq pipeline | ||
#' | ||
#' @keywords internal | ||
"_PACKAGE" | ||
|
||
## usethis namespace: start | ||
## usethis namespace: end | ||
NULL |
Oops, something went wrong.