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 / partyData_StringPercent_to_dblPercent.R
Created December 21, 2017 16:27
Convert percent values saved as string to double Raw Raw
#Read in data
party_ready <- read_csv("Data/party_ready.csv")
#Copy data
party_time <- party_ready
#Get columns with percents
columns_with_pct <- grep("pct",colnames(party_time))
#Convert percents as strings to percents as double
@chasemc
chasemc / NamedColors-to-HEX.R
Created January 8, 2018 15:05
Convert a vector of named colors to HEX values in R
# cols is a vector of named colors
# First we convert the named colors to rgb, and store the values in a list
rgbVals<-lapply(cols,col2rgb)
# Then convert the list to a data frame and flip it
rgbVals<-t(as.data.frame(rgbVals,col.names = seq(1,length(rgbVals),by=1)))
# Then we convert the rgb values to HEX
hexVal<-sapply(1:length(rgbVal[,1]),function(x){ rgb(rgbVal[x,"red"],rgbVal[x,"green"],rgbVal[x,"blue"],maxColorValue = 255) })
@chasemc
chasemc / ThingsToAdddTo_code.iss
Created February 5, 2018 18:48
Adding Rtools dependency to RInno
#define IncludeRtools true
#--------------------------------------
#if IncludeRtools
Source: "Rtools34.exe"; DestDir: "{tmp}"; Check: RtoolsNeeded
#endif
@chasemc
chasemc / Old PCA RGL.R
Created February 15, 2018 16:19
Old PCA RGL
#
# output$pcaplot3d <- renderRglwidget({
#
# e<-pcaCalculation()
#
# if(!any(names(e) == 'd')){
# e<-cbind(e,d=rep("black",length(e[,1])))
# }
#
@chasemc
chasemc / old PCA GGPLOT.R
Created February 15, 2018 16:20
old PCA GGPLOT
# e<-pcaCalculation()
#
# if(any(names(e) == 'd')){
#
# p<-ggplot(e,aes(Dim.1,Dim.2,label=nam,col=factor(e$d)))+
# geom_text()+
# xlab("Dimension 1")+
# ylab("Dimension 2")+
# ggtitle("Zoomable PCA of Protein MALDI Spectra")+
@chasemc
chasemc / gist:fc17bdd0b4914abca855efd5bb14ad6b
Created February 28, 2018 16:15
Install some packages
if(!length(grep("mzR",row.names(installed.packages())))){
if(!length(grep("BiocInstaller",row.names(installed.packages())))){
source("https://bioconductor.org/biocLite.R")
biocLite("BiocInstaller",suppressUpdates = T)
}
source("https://bioconductor.org/biocLite.R")
biocLite("mzR",ask=F)
}
@chasemc
chasemc / package_manager.R
Created March 14, 2018 05:14
Include pwiz package installation during initial RInno setup
# capture the current working directory
# set the package search path to the app specific library
appwd <- getwd()
applibpath <- file.path(appwd, "library")
# Load functions to ensure software dependencies and check the internet
source("utils/ensure.R")
# Create app/library if it doesn't exist (e.g. first run)
# Initialize RInno
4
MENVMSWFNIDFEIKSDNNIDKTLL
3017.418
3.918049
5
MKFYTIKLPKFLGGIVRAMLGSFRKD
3017.730
11.254379
@chasemc
chasemc / Parse-mzXML.md
Last active June 11, 2018 23:11
Parsing XML Elements from mzXML files with the R package 'XML'

Parse mzXML

Chase Clark June 11, 2018

Examples of both MALDI MS1 and LC-MS/MS files

Example of IDBac mzXML conversion output... Bruker autoFlex MALDI MS1

First few lines of mzXML file:

@chasemc
chasemc / Sponge tSNE.R
Created June 22, 2018 02:27
Messy tSNE code
spongeSmallIn <- readRDS("data/spongeSmall.rds")
spongeSmall <- MALDIquant::intensityMatrix(spongeSmallIn)
spongeSmall[is.na(spongeSmall)] <- 0.000000001
spongeSmall <- prcomp(log10(spongeSmall))
spongeSmall <- spongeSmall$x[,1:50]
z <- sapply(spongeSmallIn, function(x) x@metaData$Strain )
q <- as.data.frame(spongeSmall)
rownames(q) <- z