Skip to content

Instantly share code, notes, and snippets.

@sneumann
sneumann / fakediffreport.R
Created October 27, 2015 20:22
Faked xcms diffreport
library(multtest)
## A convenience function cut&paste from
## https://github.com/sneumann/xcms/blob/master/R/xcmsSet.R#L2052
pval <- function(X, classlabel, teststat) {
n1 <- rowSums(!is.na(X[,classlabel == 0]))
n2 <- rowSums(!is.na(X[,classlabel == 1]))
A <- apply(X[,classlabel == 0], 1, sd, na.rm=TRUE)^2/n1 ## sd(t(X[,classlabel == 0]), na.rm = TRUE)^2/n1
## TODO:
## study-variable , separated -> DONE
## assay[1]-assay[2]-assay[3]-assay[4]-assay[5]-assay[6]
## link sample - assay:
##
## MTD sample[1]-description KO15
## MTD assay[1]-sample_ref sample[1]
library(plyr) ## for rbind.fill
- id: chemont
preferredPrefix: ChemOnt
title: ChemOnt: A semantic-based ontology for chemical and biological data integration.
uri: http://classyfire.wishartlab.com/
description: "ChemOnt is comphrehensive, computable, and manually curated.
It covers >4000 chemical classes of organic and inorganic compounds. The set of classes was created
and extended by extracting common terms from the scientific literature (e.g.: IUPAC) and available databases.
The flexibility The taxonomy is currently mapped to the ChEBI and LIPID MAPS ontologies in collaboration
with the respective teams. Moreover, ChemOnt has been partially mappped to the MeSH thesaurus.
The mapping effort in this regard is ongoing. Thanks to the flexibility and simplicity of its structure
library(httr)
library(rmzTabM)
library(xcms)
library(faahKO)
data(faahko3)
faahkoMzTab <- rmzTabM::MzTab$new(
metadata=Metadata$new(
'mzTab-version' = "2.2.0-M",
'mzTab-ID' = "faahKO",
@sneumann
sneumann / pykubejob.py
Created May 25, 2021 21:49
minimum example to submit Job with pykube
import pykube
from os import environ as os_environ
# pykube imports:
try:
from pykube.config import KubeConfig
from pykube.http import HTTPClient
from pykube.objects import (
Job,
Pod
@sneumann
sneumann / metaRboomics molecular formulas
Last active September 19, 2022 14:34
Install and benchmark a number of
install.packages("microbenchmark")
install.packages("plyr")
install.packages("rcdk")
install.packages("OrgMassSpecR")
install.packages("CHNOSZ")
BiocManager::install("Rdisop")
BiocManager::install("MetaboCoreUtils")
#!/bin/bash
wget -O- https://www.chemotion-repository.net/api/v1/public/molecule.json?id=6338 |\
jq "$(cat <<EOF
{ "@context": "https://schema.org/",
"@type": "MolecularEntity",
"dct:conformsTo": { "http://purl.org/dc/terms/conformsTo": {
"@id": "https://bioschemas.org/profiles/MolecularEntity/0.5-RELEASE",
"@type": "CreativeWork" }
},
"@id": .molecule.tag.taggable_data.chemotion.doi,
@sneumann
sneumann / convertMzTab2MAF.R
Created October 18, 2022 10:53
Convert an mzTab-M to MetaboLights MAF file using rmzTabM and metabolighteR
library(rmzTabM) ## https://lifs-tools.github.io/rmzTab-m/
library(metabolighteR) ## https://aberhrml.github.io/metabolighteR/
convertMzTab2MAF <- function(mzTabfile, MAFfile) {
mzTabTable <- readMzTab(mzTabfile)
## To turn these tables into objects, use the R6 class constructor method `new()`:
mzTabObject <- MzTab$new()$fromDataFrame(mzTabTable)
metadata <- mzTabObject$metadata
@sneumann
sneumann / Chemotion2OAI.sh
Created November 16, 2022 14:45
Import Metadata from Chemotion to FIZ-OAI provider
## 1) Get paginated list of Molecules from Chemotion
## 2) extract DOI and internal chemotion ID for each molecule with `jq`
## 3) Query each molecule and convert with `jq` to (bio)schemas
## 4) Embedd the JSON in a CDATA in a minimalistic XML
## 5) Pipe the XML to the FIZ-OAI backend running at $BACKEND, e.g. localhost
export BACKEND=http://localhost:8081/oai-backend
for I in 1 2 3 4 5 6 7 8 9 10; do
wget -O- "https://www.chemotion-repository.net/api/v1/public/molecules.json?page=$I&per_page=100" |\
@sneumann
sneumann / MassBank2OAI
Created December 2, 2022 13:04
Import Metadata from MassBank DataDump to FIZ-OAI provider
#!/usr/bin/env bash
export BACKEND=http://localhost:8081/oai-backend
jq -c '.[]' DataDump-IPB.jsonld | \
while read i; do
IDENTIFIER=`echo "$i" | jq '.identifier'`
(