Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
arisp99 committed Aug 9, 2021
0 parents commit 5415449
Show file tree
Hide file tree
Showing 21 changed files with 421 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
^MIPr\.Rproj$
^\.Rproj\.user$
^README\.Rmd$
^LICENSE\.md$
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.Rproj.user
.Rhistory
.Rdata
.httr-oauth
.DS_Store
inst/doc
31 changes: 31 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Package: MIPr
Title: Collection of Functions for MIPTools Analysis
Version: 0.0.0.9000
Authors@R:
person(given = "Aris",
family = "Paschalidis",
role = c("aut", "cre"),
email = "aris.paschalidis@gmail.com",
comment = c(ORCID = "0000-0003-2247-1885"))
Description: What the package does (one paragraph).
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
Suggests:
knitr,
rmarkdown,
spelling
Language: en-US
Imports:
dplyr,
janitor,
magrittr,
readr,
rlang,
tibble,
tidyr
VignetteBuilder: knitr
Depends:
R (>= 2.10)
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2021
COPYRIGHT HOLDER: Aris Paschalidis
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2021 Aris Paschalidis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 22 additions & 0 deletions MIPr.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Version: 1.0

RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(read)
importFrom(magrittr,"%>%")
importFrom(rlang,.data)
8 changes: 8 additions & 0 deletions R/MIPr.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#' \pkg{MIPr} Collection of Functions for MIPTools Analysis
#'
#' @docType package
#' @name MIPr
#'
#' @importFrom rlang .data
#'
"_PACKAGE"
63 changes: 63 additions & 0 deletions R/read.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#------------------------------------------------
#' Read data
#'
#' Read paired data files and combine the files.
#'
#' @param alternate_table Alternate table.
#' @param coverage_table Coverage table.
#'
#' @return A tibble containing the parsed data.
#' @export
read <- function(alternate_table, coverage_table) {
alternate_table <- read_file(alternate_table, "alternate")
coverage_table <- read_file(coverage_table, "coverage")

bind_table <- dplyr::full_join(alternate_table, coverage_table,
by = c("sample", "gene_id", "gene",
"mutation_name", "exonic_func",
"aa_change", "targeted")) %>%
dplyr::mutate(dplyr::across(.data$umi_count:.data$coverage, as.numeric))
}

#------------------------------------------------
#' Read file
#'
#' Read data files.
#'
#' @param file Alternate table.
#'
#' @return Parsed file.
#'
#' @keywords internal
read_file <- function(file, type = c("alternate", "coverage")) {
data <- readr::read_csv(file, col_names = FALSE) %>%
# Take the tranpose of our matrix, making rows columns and columns rows. This
# will allows us to keep all the data in our .csv file.
tibble::rownames_to_column() %>%
tidyr::pivot_longer(-.data$rowname) %>%
tidyr::pivot_wider(names_from = .data$rowname,
values_from = .data$value) %>%
# Assign the column names of our tibble and clean them up
dplyr::select(-.data$name) %>%
janitor::row_to_names(1)
if (type == "alternate") {
data <- data %>%
# Convert out data to a long format, where now we have a column with the
# umi_count
tidyr::pivot_longer(cols = -c(.data$`Gene ID`:.data$Targeted),
names_to = "sample" ,
values_to = "umi_count")
} else if (type == "coverage") {
data <- data %>%
# Convert out data to a long format, where now we have a column with the
# coverage
tidyr::pivot_longer(cols = -c(.data$`Gene ID`:.data$Targeted),
names_to = "sample" ,
values_to = "coverage")
} else {
stop("Inocrrect type specified")
}
data <- data %>%
dplyr::relocate(sample) %>%
janitor::clean_names()
}
Binary file added R/sysdata.rda
Binary file not shown.
14 changes: 14 additions & 0 deletions R/utils-pipe.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#' Pipe operator
#'
#' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details.
#'
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @export
#' @importFrom magrittr %>%
#' @usage lhs \%>\% rhs
#' @param lhs A value or the magrittr placeholder.
#' @param rhs A function call using the magrittr semantics.
#' @return The result of calling `rhs(lhs)`.
NULL
29 changes: 29 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# MIPr

<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
<!-- badges: end -->

## Installation
To install the package, please follow the code below. In order to install,
`devtools` must be installed.
```{r, eval = FALSE}
# install.packages("devtools")
devtools::install_github("https://github.com/arisp099/MIPr")
```
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# MIPr

<!-- badges: start -->

[![Lifecycle:
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![License:
MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
<!-- badges: end -->

## Installation

To install the package, please follow the code below. In order to
install, `devtools` must be installed.

``` r
# install.packages("devtools")
devtools::install_github("https://github.com/arisp099/MIPr")
```
3 changes: 3 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MIPTools
github
https
Loading

0 comments on commit 5415449

Please sign in to comment.