diff --git a/.gitignore b/.gitignore index cd67eac..a619a9b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ .Rproj.user +*.Rproj +*.Rhistory \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f73dfc2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,2 @@ +language: r +bioc_check: true diff --git a/DESCRIPTION b/DESCRIPTION index 7c94981..c1d3133 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,19 +3,18 @@ Title: Tools for spAtial PROteOmics Version: 0.1.0 Depends: R (>= 3.6) Authors@R: - person(given = "First", - family = "Last", + person(given = "Ehsan", + family = "Karimiara", role = c("aut", "cre"), - email = "first.last@example.com", + email = "e.karimiara@gmail.com", comment = c(ORCID = "YOUR-ORCID-ID")) Description: What the package does (one paragraph). -License: What license it uses +License: file LICENSE Encoding: UTF-8 LazyData: true Imports: yaml, scater, - SingleCellExperiment, BiocGenerics, SummarizedExperiment, plyr, @@ -23,7 +22,18 @@ Imports: MASS, broom, dplyr, - tibble + tibble, + utils, + cowplot, + stats, + viridis, + ComplexHeatmap, + ggplot2, + wesanderson, Suggests: - crayon -RoxygenNote: 7.1.0 + crayon, + knitr, + rmarkdown +RoxygenNote: 7.1.1 +biocViews: Proteomics, CellBiology, Software +VignetteBuilder: knitr diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/NAMESPACE b/NAMESPACE index 88497b9..001733f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,9 +1,13 @@ # Generated by roxygen2: do not edit by hand +export(astir_paper_theme) +export(cohort_colours) +export(createHeatmap) export(get_celltypes) export(imc_exclusive_marker_score) export(jackson_basel_colours) export(patient_clinSubtype_colours) +export(patient_clinSubtype_colours_wagner) export(patient_response_colours) export(plotSpatial) export(print_marker_info) @@ -11,10 +15,14 @@ export(read_markers) export(tidy_rownames_jackson) export(to_csv) export(winsorize) +import(cowplot) +import(ggplot2) importFrom(BiocGenerics,rownames) importFrom(ComplexHeatmap,Heatmap) importFrom(ComplexHeatmap,HeatmapAnnotation) importFrom(MASS,rlm) +importFrom(SummarizedExperiment,"assay<-") +importFrom(SummarizedExperiment,"colData<-") importFrom(SummarizedExperiment,assay) importFrom(SummarizedExperiment,colData) importFrom(broom,tidy) @@ -24,9 +32,12 @@ importFrom(dplyr,left_join) importFrom(dplyr,mutate) importFrom(plyr,mapvalues) importFrom(scater,plotColData) +importFrom(stats,quantile) importFrom(stringr,str_locate) importFrom(stringr,str_sub) importFrom(tibble,tibble) importFrom(utils,data) +importFrom(utils,write.csv) importFrom(viridis,viridis) +importFrom(wesanderson,wes_palette) importFrom(yaml,read_yaml) diff --git a/R/cleaning.R b/R/cleaning.R index 29aa0f2..6e36789 100644 --- a/R/cleaning.R +++ b/R/cleaning.R @@ -9,11 +9,13 @@ #' @param sce An input \code{SummarizedExperiment} or \code{SingleCellExperiment} #' @param marker_1 The name of the first marker (normally keratin) #' @param marker_2 The name of the second marker (normally CD45/PTPRC) +#' @param assay_name Type of SingleCellExperiment #' #' @importFrom MASS rlm #' @importFrom SummarizedExperiment assay #' @importFrom broom tidy #' +#' @examples counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) #' @export imc_exclusive_marker_score <- function(sce, marker_1 = "pan Cytokeratin", diff --git a/R/colours.R b/R/colours.R index dcba3dd..1495a78 100644 --- a/R/colours.R +++ b/R/colours.R @@ -1,5 +1,6 @@ #' Celltype colours for Jackson Basel 2020 +#' @examples colors <-jackson_basel_colours() #' @export jackson_basel_colours <- function() { pal <- c("#8B5B42", "#AF4EA9", "#FFB60A", "#0AC694", "#0024DD", "#6CC1FF", @@ -28,6 +29,9 @@ jackson_basel_colours <- function() { celltype_colours } +#' Color maps of patient clinical subtypes +#' +#' @examples patient_clinSubtype_colours() #' @export patient_clinSubtype_colours <- function(){ pal <- c("#648FFF", "#785EF0", "#DC267F", "#FE6100", "#FFB000") @@ -41,6 +45,8 @@ patient_clinSubtype_colours <- function(){ clinSubtype_colours } +#' Set Wagner colour maps to patient clinical subtypes +#' @examples patient_clinSubtype_colours_wagner() #' @export patient_clinSubtype_colours_wagner <- function(){ pal <- c("#648FFF", "#785EF0", "#DC267F", "#FE6100", "#FFB000") @@ -55,6 +61,8 @@ patient_clinSubtype_colours_wagner <- function(){ clinSubtype_colours } +#' Colour maps of patient responses +#' @examples patient_response_colours() #' @export patient_response_colours <- function(){ pal <- c("#648FFF", "#785EF0", "#DC267F", "#FE6100", "#FFB000") @@ -67,7 +75,10 @@ patient_response_colours <- function(){ clinSubtype_colours } -#' @export +#' Group colors +#' @importFrom wesanderson wes_palette +#' @examples counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) +#' @export cohort_colours <- function(){ pal <- wes_palette("Darjeeling2", 4, type = c("discrete")) diff --git a/R/jackson.R b/R/jackson.R index 047e7b5..347a94b 100644 --- a/R/jackson.R +++ b/R/jackson.R @@ -12,6 +12,7 @@ #' @importFrom dplyr left_join mutate case_when filter #' @importFrom tibble tibble #' +#' @examples counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) #' @export tidy_rownames_jackson <- function(sce) { diff --git a/R/markers.R b/R/markers.R index 378a42a..46bbd13 100644 --- a/R/markers.R +++ b/R/markers.R @@ -4,6 +4,8 @@ #' #' @param path Input file path (yaml file) #' +#' @examples +#' counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) #' @export #' #' @return A marker list including cell type and state markers @@ -37,6 +39,8 @@ read_markers <- function(path) { #' #' @return Prints marker information #' +#' @examples +#' counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) #' @export #' print_marker_info <- function(markers) { diff --git a/R/plotting.R b/R/plotting.R index 45f8f38..eefd097 100644 --- a/R/plotting.R +++ b/R/plotting.R @@ -6,11 +6,17 @@ #' @param colour_by Either a feature name or column of \code{colData(sce)} #' @param x_str The column of \code{colData(sce)} that codes for the x coordinate #' @param y_str The column of \code{colData(sce)} that codes for the Y coordinate +#' @param winsorize IDK ???? +#' @param w_limits Range of probabilities to use in quantile() +#' @param exprs_values Type of SingleCellExperiment #' @param ... Additional arguments to pass to \code{plotColData} #' #' @importFrom scater plotColData -#' @importFrom SummarizedExperiment colData -#' +#' @importFrom SummarizedExperiment assay colData colData<- +#' @importFrom stats quantile +#' +#' @examples +#' counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) #' @export plotSpatial <- function(sce, colour_by = NULL, @@ -61,7 +67,9 @@ plotSpatial <- function(sce, #' @param thresh The threshold to winsorize expression values at #' #' @return A heatmap of class \code{ComplexHeatmap::Heatmap} -#' +#' +#' @examples +#' counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) #' @export #' #' @importFrom SummarizedExperiment assay colData diff --git a/R/theme.R b/R/theme.R index b3e90b6..c054b2a 100644 --- a/R/theme.R +++ b/R/theme.R @@ -1,4 +1,8 @@ #' Create a theme for all plot for the astir paper +#' +#' @import cowplot +#' @import ggplot2 +#' @examples astir_paper_theme() #' @export astir_paper_theme <- function() { cowplot::theme_cowplot(font_size = 12) + diff --git a/R/utils.R b/R/utils.R index bc78e0d..e295291 100644 --- a/R/utils.R +++ b/R/utils.R @@ -12,7 +12,12 @@ winsorize_one <- function(y, } #' Winsorize the (log) counts +#' @param sce An input \code{SummarizedExperiment} or \code{SingleCellExperiment} +#' @param exprs_values Type of input? +#' @param w_limits cut off limits? +#' @importFrom SummarizedExperiment assay<- assay #' +#' @examples counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) #' @export winsorize <- function(sce, exprs_values = "logcounts", @@ -40,7 +45,11 @@ winsorize <- function(sce, #' @param file The output file to write to #' @param include_xy Logical: should spatial location be written as first two #' columns? -#' +#' @param exprs_values The type of the SingleCellExperiment? +#' +#' @importFrom utils write.csv +#' +#' @examples counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) #' @export to_csv <- function(sce, file, @@ -64,7 +73,10 @@ to_csv <- function(sce, } #' Get cell type assignments given probability matrix +#' @param prob_mat A probability matrix? +#' @param thresh A measure for cell type assignment? #' +#' @examples counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) #' @export get_celltypes <- function(prob_mat, thresh = 0.5) { if(is.data.frame(prob_mat)) { diff --git a/man/astir_paper_theme.Rd b/man/astir_paper_theme.Rd new file mode 100644 index 0000000..01f1822 --- /dev/null +++ b/man/astir_paper_theme.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/theme.R +\name{astir_paper_theme} +\alias{astir_paper_theme} +\title{Create a theme for all plot for the astir paper} +\usage{ +astir_paper_theme() +} +\description{ +Create a theme for all plot for the astir paper +} +\examples{ +astir_paper_theme() +} diff --git a/man/cohort_colours.Rd b/man/cohort_colours.Rd new file mode 100644 index 0000000..4678f14 --- /dev/null +++ b/man/cohort_colours.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/colours.R +\name{cohort_colours} +\alias{cohort_colours} +\title{Group colors} +\usage{ +cohort_colours() +} +\description{ +Group colors +} +\examples{ +counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) +} diff --git a/man/createHeatmap.Rd b/man/createHeatmap.Rd index b1c3520..ffa23f6 100644 --- a/man/createHeatmap.Rd +++ b/man/createHeatmap.Rd @@ -28,3 +28,6 @@ A heatmap of class \code{ComplexHeatmap::Heatmap} Note that this creates a \code{Heatmap} object. To plot, call \code{draw(...)} on the returned object. } +\examples{ + counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) +} diff --git a/man/get_celltypes.Rd b/man/get_celltypes.Rd index 707ff31..0e0650d 100644 --- a/man/get_celltypes.Rd +++ b/man/get_celltypes.Rd @@ -6,6 +6,14 @@ \usage{ get_celltypes(prob_mat, thresh = 0.7) } +\arguments{ +\item{prob_mat}{A probability matrix?} + +\item{thresh}{A measure for cell type assignment?} +} \description{ Get cell type assignments given probability matrix } +\examples{ +counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) +} diff --git a/man/imc_exclusive_marker_score.Rd b/man/imc_exclusive_marker_score.Rd index 6c0b3e2..40e66f9 100644 --- a/man/imc_exclusive_marker_score.Rd +++ b/man/imc_exclusive_marker_score.Rd @@ -17,6 +17,8 @@ imc_exclusive_marker_score( \item{marker_1}{The name of the first marker (normally keratin)} \item{marker_2}{The name of the second marker (normally CD45/PTPRC)} + +\item{assay_name}{Type of SingleCellExperiment} } \description{ Implements a very basic QC test: CD45 and keratin should exhibit mutually @@ -24,3 +26,6 @@ exclusive expression, so performs a robust regression to check this trend, and reports the z-statistic. The more negative this is, the better the mutually-exclusive expression (to a first approximation). } +\examples{ +counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) +} diff --git a/man/jackson_basel_colours.Rd b/man/jackson_basel_colours.Rd index 6f7b0b2..f45822b 100644 --- a/man/jackson_basel_colours.Rd +++ b/man/jackson_basel_colours.Rd @@ -9,3 +9,6 @@ jackson_basel_colours() \description{ Celltype colours for Jackson Basel 2020 } +\examples{ +colors <-jackson_basel_colours() +} diff --git a/man/patient_clinSubtype_colours.Rd b/man/patient_clinSubtype_colours.Rd new file mode 100644 index 0000000..fe74f3a --- /dev/null +++ b/man/patient_clinSubtype_colours.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/colours.R +\name{patient_clinSubtype_colours} +\alias{patient_clinSubtype_colours} +\title{Color maps of patient clinical subtypes} +\usage{ +patient_clinSubtype_colours() +} +\description{ +Color maps of patient clinical subtypes +} +\examples{ +patient_clinSubtype_colours() +} diff --git a/man/patient_clinSubtype_colours_wagner.Rd b/man/patient_clinSubtype_colours_wagner.Rd new file mode 100644 index 0000000..11363a2 --- /dev/null +++ b/man/patient_clinSubtype_colours_wagner.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/colours.R +\name{patient_clinSubtype_colours_wagner} +\alias{patient_clinSubtype_colours_wagner} +\title{Set Wagner colour maps to patient clinical subtypes} +\usage{ +patient_clinSubtype_colours_wagner() +} +\description{ +Set Wagner colour maps to patient clinical subtypes +} +\examples{ +patient_clinSubtype_colours_wagner() +} diff --git a/man/patient_response_colours.Rd b/man/patient_response_colours.Rd new file mode 100644 index 0000000..e1902a7 --- /dev/null +++ b/man/patient_response_colours.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/colours.R +\name{patient_response_colours} +\alias{patient_response_colours} +\title{Colour maps of patient responses} +\usage{ +patient_response_colours() +} +\description{ +Colour maps of patient responses +} +\examples{ +patient_response_colours() +} diff --git a/man/plotSpatial.Rd b/man/plotSpatial.Rd index 1c8706b..b3ab09c 100644 --- a/man/plotSpatial.Rd +++ b/man/plotSpatial.Rd @@ -24,8 +24,17 @@ plotSpatial( \item{y_str}{The column of \code{colData(sce)} that codes for the Y coordinate} +\item{winsorize}{IDK ????} + +\item{w_limits}{Range of probabilities to use in quantile()} + +\item{exprs_values}{Type of SingleCellExperiment} + \item{...}{Additional arguments to pass to \code{plotColData}} } \description{ Plot the spatial variation in gene expression or colData } +\examples{ + counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) +} diff --git a/man/print_marker_info.Rd b/man/print_marker_info.Rd index ae0f187..0aa10a9 100644 --- a/man/print_marker_info.Rd +++ b/man/print_marker_info.Rd @@ -15,3 +15,6 @@ Prints marker information \description{ Print cell type and cell state marker info } +\examples{ + counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) +} diff --git a/man/read_markers.Rd b/man/read_markers.Rd index 63cb8d0..7a4075a 100644 --- a/man/read_markers.Rd +++ b/man/read_markers.Rd @@ -15,3 +15,6 @@ A marker list including cell type and state markers \description{ Read a marker yaml file } +\examples{ + counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) +} diff --git a/man/tidy_rownames_jackson.Rd b/man/tidy_rownames_jackson.Rd index 9a27135..b183b0d 100644 --- a/man/tidy_rownames_jackson.Rd +++ b/man/tidy_rownames_jackson.Rd @@ -12,3 +12,6 @@ tidy_rownames_jackson(sce) \description{ Convert from original SC_Dat.csv rownames to understandable ones } +\examples{ + counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) +} diff --git a/man/to_csv.Rd b/man/to_csv.Rd index f324d68..d22aa8c 100644 --- a/man/to_csv.Rd +++ b/man/to_csv.Rd @@ -24,8 +24,13 @@ columns?} \item{x_str}{The column of \code{colData(sce)} that codes for the x coordinate} \item{y_str}{The column of \code{colData(sce)} that codes for the Y coordinate} + +\item{exprs_values}{The type of the SingleCellExperiment?} } \description{ Writes the cell names as row names, and the (X,Y) co-ordinates as the first two columns (named \code{X} and \code{Y}). } +\examples{ +counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) +} diff --git a/man/winsorize.Rd b/man/winsorize.Rd index 8011636..e6e3803 100644 --- a/man/winsorize.Rd +++ b/man/winsorize.Rd @@ -6,6 +6,16 @@ \usage{ winsorize(sce, exprs_values = "logcounts", w_limits = c(0.05, 0.95)) } +\arguments{ +\item{sce}{An input \code{SummarizedExperiment} or \code{SingleCellExperiment}} + +\item{exprs_values}{Type of input?} + +\item{w_limits}{cut off limits?} +} \description{ Winsorize the (log) counts } +\examples{ +counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) +} diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000..097b241 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/taproom.Rmd b/vignettes/taproom.Rmd new file mode 100644 index 0000000..accd64f --- /dev/null +++ b/vignettes/taproom.Rmd @@ -0,0 +1,19 @@ +--- +title: "taproom" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{taproom} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +```{r setup} +library(taproom) +```