This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#check for and/or install dependencies | |
need<-c("RCurl","ggplot2","gridExtra","reshape2") | |
for(i in 1:length(need)){ | |
if(require(need[i], character.only = TRUE)==FALSE){ install.packages(need[i]);library(need[i], character.only = TRUE)} else { library(need[i],character.only = TRUE)} | |
} | |
if(require(pcaMethods)==FALSE){ | |
need<-c('Rcpp', 'rJava', | |
'Matrix', 'cluster', 'foreign', 'lattice', 'mgcv', 'survival') | |
for(i in 1:length(need)){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#initialize | |
library(datasets) | |
library(ggplot2) | |
#helper function (convert vector to named list) | |
namel<-function (vec){ | |
tmp<-as.list(vec) | |
names(tmp)<-as.character(unlist(vec)) | |
tmp | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KTVPXOYAKDPRHY-SOOFDHNKSA-N AAAFZMYJJHWUPN-TXICZTDVSA-N main RP01256 | |
PQGCEDQWHSBAJP-TXICZTDVSA-N AAAFZMYJJHWUPN-TXICZTDVSA-N main RP10961 | |
YXJDFQJKERBOBM-TXICZTDVSA-N AAAFZMYJJHWUPN-TXICZTDVSA-N trans RP11184 | |
ZKHQWZAMYRWXGA-KQYNXXCUSA-N AAAFZMYJJHWUPN-TXICZTDVSA-N trans RP06423 | |
RWKJTIHNYSIIHW-MEBVTJQTSA-N AAJODOMQIUQTFG-XAICKWAHSA-N main RP12160 | |
RTPWRCREAVUAOI-CGJPUGKVSA-N AAKIIQMDPGWYFD-FFZYTXIOSA-N main RP11883 | |
XLYOFNOQVPJJNP-UHFFFAOYSA-N AAKIIQMDPGWYFD-FFZYTXIOSA-N leave RP09015 | |
XLYOFNOQVPJJNP-UHFFFAOYSA-N AAMCJNYIOAHDFN-BCCCWXECSA-N leave RP09666 | |
AUFGTPPARQZWDO-YUZLPWPTSA-N ABCOOORLYAOBOZ-KQYNXXCUSA-N trans RP08184 | |
BDAGIHXWWSANSR-UHFFFAOYSA-N ABCOOORLYAOBOZ-KQYNXXCUSA-N main RP10097 |
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SMID Formula Metabolite Central Map Pathway KEGGpath KEGGid PubChem CID Lmid HMDBID MetacycID CHEBI METLIN InchiKEY Synonyms | |
11 H2O H2O Central Energy Metabolism Oxidative phosphorylation__Photosynthesis__Carbon fixation__Riboflavin metabolism map00190 C00001 962 HMDB02111 WATER 5585 3194 XLYOFNOQVPJJNP-UHFFFAOYSA-N Water | |
25361 C10H16N5O13P3 ATP Central Energy Metabolism Oxidative phosphorylation__Photosynthesis__Purine metabolism__Puromycin biosynthesis__Zeatin biosynthesis map00190 C00002 5957 HMDB00538 ATP 2359 95 ZKHQWZAMYRWXGA-KQYNXXCUSA-N Adenosine 5'-triphosphate | |
31698 C21H27N7O14P2 NAD+ Central Energy Metabolism Oxidative phosphorylation__Glutamate metabolism__Nicotinate and nicotinamide metabolism map00190 C00003 5893 HMDB00902 NAD 7422 101 BAWFJGJZGIEFAR-NNYOXOHSSA-O NAD_Nicotinamide adenine dinucleotide_DPN_Diphosphopyridine nucleotide_Nadide | |
31768 C21H29N7O14P2 NADH Central Energy Metabolism Oxidative phosphorylation map00190 C00004 439153 HMDB01487 NADH 7423 3687 BOPGDPNILDQYTO-NNYOXOHSSA-N D |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# R interface to Chemical Identifier Resolver (CIR) by the CADD Group at the NCI/NIH | |
CIRgetR<-function(id,to=c("pubchem_sid"),return.all=TRUE,progress=TRUE){ | |
#id needs to be one of the folowing types of structural ids "inchi","inchiKey" or "smiles" | |
#to can be: smiles, names, iupac_name, cas, inchi, | |
# stdinchi, inchikey, stdinchikey, | |
# ficts, ficus, uuuuu, image, # here return url do not evaluate | |
# mw, monoisotopic_mass,file, | |
# chemspider_id | |
# pubchem_sid, chemnavigator_sid, formula, chemnavigator_sid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C00005 C00006 | |
C00003 C00004 | |
C00002 C00008 | |
C00019 C00021 | |
C00007 C00027 | |
C00010 C00024 | |
C00002 C00020 | |
C00002 C00013 | |
C00002 C00009 | |
C00015 C00029 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#needed packages | |
library(andrews) | |
library(ggplot2) | |
#get some data here I use "mtcars" | |
data<-mtcars | |
fct<-as.factor(mtcars$cyl) # factor for intial grouping | |
#get andrews encoding (x and y coords) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |