Skip to content

Instantly share code, notes, and snippets.

View chasemc's full-sized avatar
:octocat:

Chase Clark chasemc

:octocat:
View GitHub Profile
@chasemc
chasemc / mapsNgenes.R
Last active May 1, 2019 14:08
mapsNgenes
# Need some subset of these packages:
#library(readxl)
#library(sf)
#library(sp)
#library(leaflet)
#library(leaflet.extras)
#library(dplyr)
#library(shiny)
#library(ggplot2)
#library(maps)
@chasemc
chasemc / outline.md
Created June 6, 2019 14:13
R/Pharma draft outline

What is continuous deployment (CD)?

Why CD?

  • Reproducible and easy deliverables
    • Missing link... how do we know an output came from the latest version of code?
    • A majority of R users can't associate a knitted report to the code version
  • Delivering R-based software (Shiny, Plumber, etc)

CD for Shiny

@chasemc
chasemc / get_id.R
Created June 18, 2019 17:16
Get genbank from strain database ID using R
gene <- "16S ribosomal RNA[product]"
a <- "ATCC 10762=ATCC 23884=CBS 434.51=DSM 40127=IFO 12594=IFO 12843=IMET 43577=ISP 5127=JCM 4008=JCM 4624=Lederle A-377=LL A-377=NCIB 8234=NRRL 2209=RIA 1129=Waksman 3550A=WC 3550"
a <- strsplit(a, "=")[[1]]
b <- glue::glue("{a}[All Fields]", sep=" ")
b <- paste0(b, collapse = " OR ")
d <- glue::glue(b, " AND {gene}")
e <- rentrez::entrez_search(db="nuccore", term=d, retmax=10)
converter <- function(inputDirectory,
ouputDirectory) {
a <- list.files(inputDirectory,
full.names = T)
b <- MALDIquantForeign::import(a,
centroided = FALSE)
@chasemc
chasemc / autoVersion.R
Created August 6, 2019 20:24
Gets current version of packages and formats for package Description
# This is not mine. I took it from: https://stackoverflow.com/a/38743324/7776088
#' Add curent version string to package dependencies
#'
#' Will \code{cat} out a cut/paste-able set of fields for a
#' \code{DESCRIPTION} file with minimum required versions for
#' each package based upon currently available package vesions
#' in CRAN.
#'
#' @param pkg package description, can be path or package name
@chasemc
chasemc / README
Last active August 29, 2019 16:22
Plot top n-peaks in a LC-MS/MS scan
profile.mzML
scan 100-110
convert to mzML
centroid.mzML
scan 100-110
peak picking = vendor
convert to mzML
cwt.mzML
---
title: '2019-09-03'
author: "Chase Clark"
date: "9/3/2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
a <- 'C:/Users/chase/Downloads/2019_10_30_christie/bruker'
file_names <- list.files(a)
file_names_path <- list.files(a, full.names = TRUE)
z <- sapply(file_names, function(x) strsplit(x, "0_")[[1]][[2]] )
@chasemc
chasemc / extracted_ion_chromatograms.R
Created November 18, 2019 18:12
Example of extracted ion chromatograms
library(ggplot2)
library(mzR)
mass <- c( 654.3920, 668.3920)
numCores <- parallel::detectCores()
numCores <- ifelse(numCores > 2,
numCores - 1,
1)
@chasemc
chasemc / parallel_msconvert.R
Last active November 25, 2019 18:37
Run msconvert in parallel from R
# Requires IDBac function findMSconvert()
parallel_msconvert <- function(directory){
# File paths
raw_path <- file.path(directory)
raw_files <- list.files(raw_path,
full.names = TRUE)
mzml_dir <- file.path(dirname(raw_path),
"mzml")
dir.create(mzml_dir)