Skip to content

Commit

Permalink
docs: document all params
Browse files Browse the repository at this point in the history
  • Loading branch information
kelly-sovacool committed Oct 8, 2024
1 parent 10bae60 commit 9df94f0
Show file tree
Hide file tree
Showing 20 changed files with 311 additions and 91 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(counts_dat_to_matrix)
export(calc_cpm)
export(create_reneeDataSet_from_dataframes)
export(create_reneeDataSet_from_files)
export(filter_counts)
Expand Down
7 changes: 5 additions & 2 deletions R/0_renee-class.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#' reneeDataSet class
#'
#' @param count_dat expected gene counts from RSEM as a data frame or tibble.
#' Must contain a `gene_id` column and a column for each sample ID in the metadata.
#' @param sample_meta_dat sample metadata as a data frame or tibble.
#' Must contain a `sample_id` column.
#' @param counts_lst named list of dataframes containing counts, e.g. expected gene counts from RSEM. Each data frame is expected to contain a `gene_id` column and a column for each sample ID in the metadata.
#'
#'
reneeDataSet <- S7::new_class("renee",
Expand Down Expand Up @@ -34,6 +33,8 @@ reneeDataSet <- S7::new_class("renee",
#'
#' @param sample_meta_filepath path to tsv file with sample IDs and metadata for differential analysis.
#' @param gene_counts_filepath path to tsv file of expected gene counts from RSEM.
#' @param count_type type to assign the values of `gene_counts_filepath` to in the `counts` slot
#' @param sample_id_colname name of the column in `sample_meta_filepath` that contains the sample IDs
#'
#' @return reneeDataSet object
#' @export
Expand Down Expand Up @@ -67,6 +68,8 @@ create_reneeDataSet_from_files <- function(sample_meta_filepath, gene_counts_fil
#' Construct a reneeDataSet object from data frames
#'
#' @inheritParams reneeDataSet
#' @inheritParams create_reneeDataSet_from_files
#' @param count_dat data frame of feature counts (e.g. expected gene counts from RSEM)
#'
#' @return reneeDataSet object
#' @export
Expand Down
4 changes: 3 additions & 1 deletion R/counts.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ calc_cpm_df <- function(dat, gene_colname = "gene_id", ...) {
gene_ids <- dat %>% dplyr::pull(gene_colname)
row_names <- rownames(dat)
dat_cpm <- dat %>%
dplyr::select(-any_of(gene_colname)) %>%
dplyr::select(-tidyselect::any_of(gene_colname)) %>%
as.matrix() %>%
edgeR::cpm(...) %>%
as.data.frame()
Expand All @@ -61,7 +61,9 @@ calc_cpm_df <- function(dat, gene_colname = "gene_id", ...) {
#' @keywords internal
#'
#' @examples
#' \dontrun{
#' counts_dat_to_matrix(head(gene_counts))
#' }
counts_dat_to_matrix <- function(counts_tbl, gene_colname = "gene_id") {
gene_colnames <- c("gene_id", "GeneName", "gene_name", "Gene", gene_colname) %>%
unique()
Expand Down
80 changes: 42 additions & 38 deletions R/filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,56 @@
#' another based on unsupervised clustering.
#'
#'
#' @param renee_ds
#' @param gene_names_column
#' @param sample_names_column
#' @param group_column
#' @param label_column
#' @param columns_to_include
#' @param outlier_samples_to_remove
#' @param minimum_count_value_to_be_considered_nonzero
#' @param minimum_number_of_samples_with_nonzero_counts_in_total
#' @param use_group_based_filtering
#' @param minimum_number_of_samples_with_nonzero_counts_in_a_group
#' @param principal_component_on_x_axis
#' @param principal_component_on_y_axis
#' @param legend_position_for_pca
#' @param point_size_for_pca
#' @param add_label_to_pca
#' @param label_font_size
#' @param label_offset_y_
#' @param label_offset_x_
#' @param samples_to_rename_manually
#' @param color_histogram_by_group
#' @param set_min_max_for_x_axis_for_histogram
#' @param minimum_for_x_axis_for_histogram
#' @param maximum_for_x_axis_for_histogram
#' @param legend_position_for_histogram
#' @param legend_font_size_for_histogram
#' @param number_of_histogram_legend_columns
#' @param colors_for_plots
#' @param number_of_image_rows
#' @param interactive_plots
#' @param plot_correlation_matrix_heatmap
#' @param renee_ds reneeDataSet object (see `create_reneeDataSet_from_dataframes()`)
#' @param count_type the type of counts to use -- must be a name in the counts slot (`renee_ds@counts`)
#' @param gene_names_column The column from your input Counts Matrix containing the Feature IDs (Usually Gene or Protein ID). This is usually the first column of your input Counts Matrix. Only columns of Text type from your input Counts Matrix will be available to select for this parameter.
#' @param sample_names_column The column from your input Sample Metadata table containing the sample names. The names in this column must exactly match the names used as the sample column names of your input Counts Matrix. Only columns of Text type from your input Sample Metadata table will be available to select for this parameter.
#' @param group_column The column from your input Sample Metadata table containing the sample group information. This is usually a column showing to which experimental treatments each sample belongs (e.g. WildType, Knockout, Tumor, Normal, Before, After, etc.). Only columns of Text type from your input Sample Metadata will be available to select for this parameter.
#' @param label_column The column from your input Sample Metadata table containing the sample labels as you wish them to appear in the plots produced by this template. This can be the same Sample Names Column. However, you may desire different labels to display on your figure (e.g. shorter labels are sometimes preferred on plots). In that case, select the column with your preferred Labels here. The selected column should contain unique names for each sample.
#' @param columns_to_include Which Columns would you like to include? Usually, you will choose to a feature ID column (e.g. gene or protein ID) and all sample columns. Columns excluded here will be removed in this step and from further analysis downstream of this step.
#' @param outlier_samples_to_remove A list of sample names to remove from the analysis.
#' @param use_cpm_counts_to_filter If no transformation has been been performed on counts matrix (eg Raw Counts) set to TRUE. If TRUE counts will be transformed to CPM and filtered based on given criteria. If gene counts matrix has been transformed (eg log2, CPM, FPKM or some form of Normalization) set to FALSE. If FALSE no further transformation will be applied and features will be filtered as is. For RNAseq data RAW counts should be transformed to CPM in order to properly filter.
#' @param minimum_count_value_to_be_considered_nonzero Minimum count value to be considered non-zero for a sample
#' @param minimum_number_of_samples_with_nonzero_counts_in_total Minimum number of samples (total) with non-zero counts
#' @param use_group_based_filtering If TRUE, only keeps features (e.g. genes) that have at least a certain number of samples with nonzero CPM counts in at least one group
#' @param minimum_number_of_samples_with_nonzero_counts_in_a_group Only keeps genes that have at least this number of samples with nonzero CPM counts in at least one group
#' @param make_plots whether to create plots
#' @param principal_component_on_x_axis The principle component to plot on the x-axis for the PCA plot. Choices include 1, 2, 3, ... (default: 1)
#' @param principal_component_on_y_axis The principle component to plot on the y-axis for the PCA plot. Choices include 1, 2, 3, ... (default: 2)
#' @param legend_position_for_pca legend position for the PCA plot
#' @param point_size_for_pca geom point size for the PCA plot
#' @param add_label_to_pca label points on the PCA plot
#' @param label_font_size label font size for the PCA plot
#' @param label_offset_y_ label offset y for the PCA plot
#' @param label_offset_x_ label offset x for the PCA plot
#' @param samples_to_rename_manually If you do not have a Plot Labels Column in your sample metadata table, you can use this parameter to rename samples manually for display on the PCA plot. Use "Add item" to add each additional sample for renaming. Use the following format to describe which old name (in your sample metadata table) you want to rename to which new name: old_name: new_name
#' @param color_histogram_by_group Set to FALSE to label histogram by Sample Names, or set to TRUE to label histogram by the column you select in the "Group Column Used to Color Histogram" parameter (below). Default is FALSE.
#' @param set_min_max_for_x_axis_for_histogram whether to set min/max value for histogram x-axis
#' @param minimum_for_x_axis_for_histogram x-axis minimum for histogram plot
#' @param maximum_for_x_axis_for_histogram x-axis maximum for histogram plot
#' @param legend_position_for_histogram legend position for the histogram plot. consider setting to 'none' for a large number of samples.
#' @param legend_font_size_for_histogram legend font size for the histogram plot
#' @param number_of_histogram_legend_columns number of columns for the histogram legend
#' @param colors_for_plots Colors for the PCA and histogram will be picked, in order, from this list. If you have >12 samples or groups, program will choose from a wide range of random colors
#' @param number_of_image_rows number of rows for the plot image. 1 = side-by-side, 2 = stacked
#' @param interactive_plots set to TRUE to make PCA and Histogram plots interactive with `plotly`, allowing you to hover your mouse over a point or line to view sample information. The similarity heat map will not display if this toggle is set to TRUE. Default is FALSE.
#' @param plot_correlation_matrix_heatmap Data sets with a large number of samples may be too large to create a correlation matrix heat map. If this template takes longer than 5 minutes to run, Toggle switch to FALSE and the correlation matrix will not be be created. Default is TRUE.
#'
#' @return reneeDataSet with filtered counts
#' @return `reneeDataSet` with filtered counts
#' @export
#'
#' @examples
#' renee_ds <- create_reneeDataSet_from_dataframes(
#' as.data.frame(nidap_sample_metadata),
#' as.data.frame(nidap_clean_raw_counts),
#' sample_id_colname = "Sample"
#' )
#' set.seed(10)
#' renee_ds2 <- renee_ds %>%
#' calc_cpm() %>%
#' filter_counts()
#' head(renee_ds2@counts$filt)
#' ) %>%
#' calc_cpm(gene_colname = "Gene") %>%
#' filter_counts(
#' sample_names_column = "Sample",
#' gene_names_column = "Gene"
#' )
#' head(renee_ds@counts$filt)
#'
filter_counts <- function(renee_ds,
count_type = "raw",
Expand Down
2 changes: 2 additions & 0 deletions R/metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#'
#' @param meta_tbl tibble with `sample_id` column
#'
#' @inheritParams create_reneeDataSet_from_files
#'
#' @return dataframe where row names are the sample IDs
#' @export
#'
Expand Down
23 changes: 23 additions & 0 deletions man/as_integer_df.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions man/calc_cpm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions man/calc_cpm_df.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/counts_dat_to_matrix.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions man/create_reneeDataSet_from_dataframes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions man/create_reneeDataSet_from_files.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9df94f0

Please sign in to comment.