Skip to content

Instantly share code, notes, and snippets.

@MatteoLacki
Created March 4, 2020 14:26
Show Gist options
  • Save MatteoLacki/64c7fa7d6681918b70c0b0ce177f8a7d to your computer and use it in GitHub Desktop.
Save MatteoLacki/64c7fa7d6681918b70c0b0ce177f8a7d to your computer and use it in GitHub Desktop.
Running OHeLa500 Benchmark
# Comparing different executions of the same isoquant projects
# install.packages("igraph")
library(LFQBench2)
library(stringr)
library(igraph)
library(purrr)
is.error <- function(x) inherits(x, "try-error")
dp = "/mnt/ms/symphony/HELA_BENCHMARK/2020_02_18/REPEAT_WITH_SETTINGS_OF_TeslaS/"
comps = list.files(dp)
peptides_names = Sys.glob(file.path(dp,'*.csv'))
names(peptides_names) = sapply(str_split(basename(peptides_names), '_OHe[Ll]a500_'), '[',1)
proteins_names = Sys.glob(file.path(dp,'*.xlsx'))
names(proteins_names) = sapply(str_split(basename(proteins_names), '_OHe[Ll]a500_'), '[',1)
peptides = lapply(peptides_names, function(x) try({read_wide_report(x)}))
proteins = lapply(proteins_names, function(x) try({read_wide_report(x, skip=1, sheet="TOP3 quantification")}))
any(sapply(peptides, is.error))
any(sapply(proteins, is.error))
comparator = function(x){
A = x[[1]]
B = x[[2]]
if((nrow(A) == nrow(B))&(ncol(A) == ncol(B))){ return(all(A==B, na.rm=T)) }
else{
return(FALSE)
}
}
compare_reportes = function(x, I_col_pattern, additional_cols=NULL){
x_I_all = lapply(x, get_intensities, I_col_pattern=I_col_pattern)
x_I = lapply(x_I_all, '[[',1)
if(!is.null(additional_cols)){
more_cols = lapply(x, function(y) y[,additional_cols, with=F])
x_I = map2(x_I, more_cols, cbind)
}
x_designs = lapply(x_I_all, '[[', 2)
design = x_designs[[1]]
icols = as.character(design$I_col_name)
x_ord_I = lapply(x_I,function(x){
setorderv(x, cols=icols)
x
})
x_ord = lapply(peptides, function(x) x[order(sequence, modifier, type)])
res = combn(x_ord_I, 2, simplify=T, FUN=comparator)
n = combn(names(x), 2)
names(res) = paste(n[1,], n[2,], sep=':')
res
}
GP = compare_reportes(peptides, "intensity in .* (:cond:.)", c('sequence', 'modifier'))
all(GP)
GR = compare_reportes(proteins, 'OHe.* (:cond:.)', c('accession', 'entry'))
all(GR)
to_graph = function(r, directed=F, ...){
df = str_split(names(r),':', simplify=T)[r,]
graph_from_data_frame(df, directed=directed, ...)
}
gp = to_graph(GP)
plot(gp)
gr = to_graph(GR)
plot(gr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment