Skip to content

Instantly share code, notes, and snippets.

View dgrapov's full-sized avatar

Dmitry Grapov dgrapov

View GitHub Profile
@dgrapov
dgrapov / test.r
Last active December 10, 2015 22:48
test
#test
test<-function(){print("hello world!")}
#purpose: model the relationship between effects size, sample size and power
# holding the significance level constant (p = 0.05) for three of the most common statistical tests:
# 1) t-Test (two-sample)
# then visualize the results for medium small, medium and large effect sizes (0.2,0.5,0.8 ; http://www.uccs.edu/lbecker/effect-size.html)
#Need pwr package
if(!require(pwr)){install.packages("pwr");library("pwr")}
# t-TEST
#load devium (or any other package) from github repo
source.git.hub<-function(url = "https://github.com/dgrapov/devium/tree/master/R")
{
if(require(RCurl)==FALSE){install.packages("RCurl");library(RCurl)} else { library(RCurl)}
#get the names of all scripts to source
obj<-getURL("https://github.com/dgrapov/devium/tree/master/R",ssl.verifypeer=FALSE)
tmp<-strsplit(obj,'href=\"/')
tmp2<-unlist(strsplit(as.character(unlist(tmp)),'class'))
scripts<-gsub("/blob","",gsub('\" ',"",tmp2[grep("dgrapov/devium/blob/master/R/",tmp2)])) # fix formatting
@dgrapov
dgrapov / CID_KEGG pairs
Last active December 13, 2015 19:39
CID_KEGG pairs
689043 C01197
6443013 C14762
6443013 C14762
6446027 C14765
6446027 C14765
11954058 C14813
6439873 C16326
6439873 C16326
1004 C00009
1023 C00013
C00005 C00006
C00003 C00004
C00002 C00008
C00019 C00021
C00007 C00027
C00010 C00024
C00002 C00020
C00002 C00013
C00002 C00009
C00015 C00029
19 GLDQAMYCGOIJDV-UHFFFAOYSA-N
36 RNQHMTFBUSSBJQ-UHFFFAOYSA-N
45 ROBFUDYVXSDBQM-UHFFFAOYSA-N
49 QHKABHOOEWYVLI-UHFFFAOYSA-N
51 KPGXRSRHYNQIFN-UHFFFAOYSA-N
58 TYEYBOSBBBHJIV-UHFFFAOYSA-N
70 BKAJNAXTPSGJCU-UHFFFAOYSA-N
71 FGSBNBBHOZHUBO-UHFFFAOYSA-N
72 YQUVCSBJEUQKSH-UHFFFAOYSA-N
76 FMGSKLZLMKYGDP-UHFFFAOYSA-N
@dgrapov
dgrapov / inchi code
Last active December 13, 2015 20:18
InChI=1S/C7H6O4/c8-5-3-1-2-4(6(5)9)7(10)11/h1-3,8-9H,(H,10,11)
InChI=1S/C7H12O5/c1-3(2)4(6(9)10)5(8)7(11)12/h3-5,8H,1-2H3,(H,9,10)(H,11,12)
InChI=1S/C3H4O5/c4-1(2(5)6)3(7)8/h1,4H,(H,5,6)(H,7,8)
InChI=1S/C5H8O3/c1-3(2)4(6)5(7)8/h3H,1-2H3,(H,7,8)
InChI=1S/C5H6O5/c6-3(5(9)10)1-2-4(7)8/h1-2H2,(H,7,8)(H,9,10)
InChI=1S/C4H6O3/c1-2-3(5)4(6)7/h2H2,1H3,(H,6,7)
InChI=1S/C6H10O3/c1-4(2)3-5(7)6(8)9/h4H,3H2,1-2H3,(H,8,9)
InChI=1S/C6H8O5/c7-4(6(10)11)2-1-3-5(8)9/h1-3H2,(H,8,9)(H,10,11)
InChI=1S/C7H6O4/c8-5-2-1-4(7(10)11)3-6(5)9/h1-3,8-9H,(H,10,11)
InChI=1S/C19H28O2/c1-18-9-7-13(20)11-12(18)3-4-14-15-5-6-17(21)19(15,2)10-8-16(14)18/h3,13-16,20H,4-11H2,1-2H3
@dgrapov
dgrapov / Orthogonal Signal Correction (OSC) for PLS models OSC-PLS (OPLS)
Last active November 28, 2023 03:28
Orthogonal Signal Correction for PLS models (OPLS)
#see updated code base and some examples in the function "test"
# https://github.com/dgrapov/devium/blob/master/R/Devium%20PLS%20%20and%20OPLS.r
#Orthogonal Signal Correction for PLS models (OPLS)
#adapted from an example in the book <a href="http://www.springer.com/life+sciences/systems+biology+an+bioinfomatics/book/978-3-642-17840-5">"Chemometrics with R by Ron Wehrens"</a>
#this code requires the following packages:
need.packages<-c("pls", # to generate PLS models
"ggplot2" ) # to plot results
@dgrapov
dgrapov / metabolomic network.R
Last active December 15, 2015 18:49
Tutorial code for making edge lists for biochemical and chemical similarity networks
#load needed functions: R package in progress - "devium", which is stored on github
source("http://pastebin.com/raw.php?i=Y0YYEBia")
# get sample chemical identifiers here:https://docs.google.com/spreadsheet/ccc?key=0Ap1AEMfo-fh9dFZSSm5WSHlqMC1QdkNMWFZCeWdVbEE#gid=1
#Pubchem CIDs = cids
cids # overview
nrow(cids) # how many
str(cids) # structure, wan't numeric
cids<-as.numeric(as.character(unlist(cids))) # hack to break factor
@dgrapov
dgrapov / max intensity mass to charge pair.r
Created April 4, 2013 21:52
Data processing script to get maximum m/z ion intensity pair from Agilent recursive analysis
#directory (file path) where the file is
#note make sure all \ are changed to \\ or /
dir<-"ZZZ"
setwd(dir) # change directory
#name of file, should be .csv
file.name<-"XXX.csv"
#load data into R this assumes there is a header
input<-read.csv(file.name, header = TRUE)