diff --git a/NAMESPACE b/NAMESPACE index 1ae3984ecd4a3fd299c824ae0f780fb02e6bcef3..7522e1516e0e4f88ca8da9c2c745643da981ea83 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,10 +1,14 @@ # Generated by roxygen2: do not edit by hand +export(add_snps) export(calculate_lr) +export(find_cpts) export(read_axiom) export(standardise_lr) export(standardize_lr) +import(changepoint) import(dplyr) +import(plyranges) import(readr) import(stringr) import(tidyr) diff --git a/R/add_snps.R b/R/add_snps.R new file mode 100644 index 0000000000000000000000000000000000000000..df0a2d91c9f9da2c90cbe86a15718ffc2a16ca77 --- /dev/null +++ b/R/add_snps.R @@ -0,0 +1,38 @@ +#' Add SNPs data +#' +#' @param lr lr values +#' @param path_to_snps file containing the list of SNPs (three columns needed : 'probeset_id', 'chromosome', 'position') +#' @param rm_unknown whether or not to remove rows when 'chromosome' or 'position' is missing (defaults to TRUE) +#' +#' @return a [tibble()] +#' @export +#' +#' @examples +#' \dontrun{ +#' add_snps(lr, path_to_snps, rm_unknown = TRUE) +#' } + +add_snps <- function(lr, path_to_snps, rm_unknown = TRUE) { + + # Set NULL variables + + file_name <- probeset_id <- NULL + + snps <- readr::read_delim(path_to_snps) |> + dplyr::select(probeset_id, chromosome, position) + + lr <- lr |> + dplyr::left_join(snps) |> + dplyr::select(file_name, chromosome, probeset_id, position, + dplyr::everything()) |> + dplyr::arrange(file_name, chromosome, position) + + if (rm_unknown == TRUE) { + lr <- lr |> + tidyr::drop_na(chromosome, position) + } + + # Assign to Global Environment + assign(x = "lr", value = lr, pos = ".GlobalEnv") + +} diff --git a/misc/find_cpts.R b/R/find_cpts.R similarity index 100% rename from misc/find_cpts.R rename to R/find_cpts.R diff --git a/man/add_snps.Rd b/man/add_snps.Rd new file mode 100644 index 0000000000000000000000000000000000000000..4b10d75877053f35813af4383842a6fd6cd4b373 --- /dev/null +++ b/man/add_snps.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add_snps.R +\name{add_snps} +\alias{add_snps} +\title{Add SNPs data} +\usage{ +add_snps(lr, path_to_snps, rm_unknown = TRUE) +} +\arguments{ +\item{lr}{lr values} + +\item{path_to_snps}{file containing the list of SNPs (three columns needed : 'probeset_id', 'chromosome', 'position')} + +\item{rm_unknown}{whether or not to remove rows when 'chromosome' or 'position' is missing (defaults to TRUE)} +} +\value{ +a \code{\link[=tibble]{tibble()}} +} +\description{ +Add SNPs data +} +\examples{ +\dontrun{ +add_snps(lr, path_to_snps, rm_unknown = TRUE) +} +} diff --git a/man/find_cpts.Rd b/man/find_cpts.Rd new file mode 100644 index 0000000000000000000000000000000000000000..a51851778ad4291f2d95dddb3de43d4ef9a2db91 --- /dev/null +++ b/man/find_cpts.Rd @@ -0,0 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/find_cpts.R +\name{find_cpts} +\alias{find_cpts} +\title{Find changepoints in lrn data} +\usage{ +find_cpts( + lr_st, + calc = "mean", + var = "lr_st_ref", + method = "BinSeg", + penalty = "MBIC", + pen_value = 0, + max_cpts = 3, + count_otvs = TRUE +) +} +\arguments{ +\item{lr_st}{standardized lr values} + +\item{calc}{changepoints will be calculated w.r.t. this value ("mean", "var" or "mean_var")} + +\item{var}{variable to be used for changepoint detection} + +\item{method}{changepoint detection method (defaults to "BinSeg")} + +\item{penalty}{changepoint detection penalty (defaults to "MBIC")} + +\item{pen_value}{penalty value (defaults to 0)} + +\item{max_cpts}{maximum number of changepoints (defaults to 3)} + +\item{count_otvs}{whether or not to add number of OTVs in detected segments (defaults to TRUE)} +} +\value{ +a \code{\link[=tibble]{tibble()}} +} +\description{ +Find changepoints in lrn data +} +\examples{ +\dontrun{ +find_cpts(lr_st, calc = "mean", var = "lr_st_ref", method = "BinSeg", +penalty = "MBIC", pen_value = 0, max_cpts = 3, count_otvs = TRUE) +} +}