sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
bcaa567ddc59dde4447312ab02956bdf77628496c460f8c44bb381f0f8fbd736
R
1,052
40
ps <- phyloseq::phyloseq( otu_table = otu_table( matrix( sample(100, 40), nrow = 2, dimnames = list( c("feature1", "feature2"), paste0("sample", 1:20) ) ), taxa_are_rows = TRUE ), tax_table = tax_table( ...
7937fc06bd64f8d36d7ef3841bc2f5ddf6615b516ece5c90bc0c49edd1399a3c
R
1,073
39
library(data.table) setwd("~/work/ibs") tissues_dir = "~/archive/gtex/GTEx_Analysis_v7_eQTL_all_associations" tissues = gsub(".allpairs.txt$","",list.files(tissues_dir,pattern=".allpairs.txt$")) exclude="" tissues = tissues[!(tissues %in% exclude)] print(tissues) save_gene = function(X,path_prefix){ path = past...
344bfb8c18df6787d423aaa2e24616f3920f164dabfd7be589be1d16e0dc8c07
R
1,077
24
## Code for plotting forecasts for a visual ## you should make sure you install the latest version of covidHubUtils: ## remotes::install_github("reichlab/covidHubUtils") library(covidHubUtils) ## plot inc death forecasts forecast_data_deaths <- load_forecast_files_repo(file_paths = "data-processed/COVIDhub-ensemble...
3530e7870cbc0947498f55d4fb5b4ff6ad505d47b532c01b84353615b9fd6cd2
R
1,081
30
#!/usr/bin/Rscript library(tidyverse) args <- commandArgs(trailingOnly=TRUE) fi_cfg <- args[1] df_cfg <- read_tsv(fi_cfg) dio <- df_cfg %>% filter(key=="dir_out") %>% pull(value) str_cells <- df_cfg %>% filter(key=="cells") %>% pull(value) cells <- sort(unique(str_split(str_cells, ",", simplify=TRUE)[1,])) dio_numb...
6f2c2190383e87359534ddbc6fda2b0370b2cacb137ee27928dd26b703686d0f
R
1,108
26
# Basic setups ------------------------------------------------------------ library(dplyr) setwd('/sdata/images/projects/UKBIOBANK/users/Shen/iv.ABCD/release2.0.1/FamilialRisk_PGRS_MDD') # A table for familial risk to bulk measure of depression ----------------- target.table=famRisk.Depre_bulk_measures target.tab...
4258bb52255876c6c15c825ead8bf557edabe1adff1dbedb5416f159f461c52e
R
1,111
29
#' Get a forecast file #' #' @param f file path #' @return a data.frame of forecast data #' read_forecast_file <- function(f) { data.table::fread(f, colClasses =c( "forecast_date" = "Date", "target" = "character", "targ...
47d792ce4daaea74f76a186510dd11c5d3f51bf8fcd92637cee80d9658365c10
R
1,128
29
test_that("add missing levels: keep abundance is lower than 1", { data(oxygen) oxygen_feature <- otu_table(oxygen) feature <- add_missing_levels(oxygen_feature) expect_true(max(feature) <= 1) expect_true(min(feature) >= 0) }) test_that("check whether taxa has level prefix", { prefix <- paste0(...
ea4635ba7a50ef6e96a83667691d217450207159c4c3eeb138069390c2350373
R
1,131
38
local({ if(!exists('getCurrentScript')) { getCurrentScript = function() { lastScriptSourced = tail(unlist(lapply(sys.frames(), function(env) env$ofile)), 1) if (is.null(lastScriptSourced)) { # No script sourced, checking invocation through Rscript cmdArgs = commandArgs(trailingO...
e57a263b8e81e7cc2e3ed819ead8a9706fc6dda01baedfd56639e82cb699ef46
R
1,148
43
library(readr) psm = read_csv(list.files(pattern = 'psm\\.csv$')[1]) deltadot_result = read_csv(list.files(pattern = '\\.result\\.csv$')[1], trim_ws = TRUE) deltadot_result = local({ result = deltadot_result result = subset(result, rank == 1) result }) deltadot_result = local({ index = match( sprintf('%...
0f34b023b197c4529aff1a074fbf3db3278c4cc421811ab61244d97b7243a25a
R
1,153
36
ls.correction <- function(TargetResult,TargetCol,TargetVal,ColtoCorr){ tmp.loc = TargetResult[,TargetCol]==TargetVal cl.name = paste0('p.cor.',TargetCol) tmp.dat = TargetResult[tmp.loc,] %>% mutate(p.cor=p.adjust(.[,ColtoCorr],method='fdr')) colnames(tmp.dat)[ncol(tmp.dat)]=cl.name return(tmp.dat) } wh...
a043986b115d17dc56b47ca2f9180b8c1583f144b29f06d4b97859975caa84c6
R
1,159
36
test_that("nmarker method", { mm <- microbiomeMarker( marker_table = marker_table(data.frame( feature = c("speciesA", "speciesB"), enrich_group = c("groupA", "groupB"), ef_logFC = c(-2, 2), pvalue = c(0.01, 0.01), padj = c(0.01, 0.01), ...
e35c18d07d414e4d5cf04eb687d8dacc2153aad55352e47bea47ce1beb7bda16
R
1,183
47
if (FALSE) { zero_neg_lb <- ANCOMBC:::get_struc_zero( data.frame(otu_table(ecam)), as(sample_data(ecam), "matrix"), "delivery", neg_lb = TRUE ) write.csv( data.frame(zero_neg_lb), file = test_path("data", "ancom-zero_neg_lb.csv") ) zero <- ANCOMBC:::ge...
3586acb37b074ca11c3e98236d0c8e10a7d9acfc14987060c620ed2151ab7b90
R
1,214
58
#' @importMethodsFrom phyloseq ntaxa #' @importFrom phyloseq ntaxa #' @export #' @exportMethod ntaxa phyloseq::ntaxa #' @importMethodsFrom phyloseq nsamples #' @importFrom phyloseq nsamples #' @export #' @exportMethod nsamples phyloseq::nsamples #' @importMethodsFrom phyloseq otu_table #' @importFrom phyloseq otu_tab...
aae7501bb8c98494ed0f68b3b8541d268dcf3ad8f3a13e1b1256a61352564126
R
1,224
45
data("caporaso") data("pediatric_ibd") test_that("check confounding variables", { expect_error( check_confounder(caporaso, "target_var"), "`target_var` must be contained in the meta data") expect_error( check_confounder(pediatric_ibd, target_var = "Class"), "No confounding var" ...
cd6d120743ace6444d46fcf4da92bbd7cb3424e0188911be3e1ec0f098446d99
R
1,234
60
setwd("~/Desktop/FirstModel/") library(magrittr) library(dplyr) library(ggplot2) library(rstan) library(tidybayes) library(emmeans) library(broom) library(brms) library(modelr) library(forcats) library(cowplot) library(RColorBrewer) library(gganimate) library(ggdist) library(loo) theme_set(theme_tidybayes() + panel_b...
a2ff16e95d382f716969e6c9c6792f42a3298b645385b46d14a33da6bdb6cdf6
R
1,263
37
library(readr) lapply(list.files(pattern = '\\.peptide\\.csv$'), function(f) { peptides = read_csv(f) lapply(2:3, function(charge) { peprec = data.frame( spec_id = paste0( peptides$sequence, '_', charge, '_', peptides$modification ), modifications = sub('\\|$', '', paste( ...
562257393a541491d4a99ff4bc5529345ab5fe0532f6113cf4f8229122e3910b
R
1,266
30
# Basic setups ------------------------------------------------------------ library(dplyr) setwd('/sdata/images/projects/UKBIOBANK/users/Shen/iv.ABCD/release2.0.1/FamilialRisk_PGRS_MDD') load('result/i.Main_result/FAMrisk.behav.MainModel.RData') # A table for familial risk to reporter difference in bulk measures ---...
8f2c8f65128cfc4b5d30d3f058dec7c78933deb202441ae5642dee77d610921e
R
1,266
33
read.mgf = function(file) { lines = readLines(con = file) begin.indexs = grep(pattern = 'BEGIN IONS', x = lines) end.indexs = grep(pattern = 'END IONS', x = lines) lapply(1:length(begin.indexs), function(i) { internal.lines = lines[begin.indexs[i]:end.indexs[i]] fields.indexs = grep(pattern =...
552ea6bf00fa06b0eed3fd4749e9ee97d9c558a78fd95853bec0edf1c70c1f66
R
1,275
44
library(readr) ce = 34 charges = 2:3 lapply(list.files(pattern = '\\.peptide\\.csv$'), function(file) { peptides = read_csv(file) lapply(charges, function(charge) { modified_sequence = peptides$sequence ox = grep('M[0-9]+\\(Oxidation\\)', peptides$modification) if (length(ox) > 0) { modified_...
54e11dc9082808d5e61832fec2e96b66c676bf0adad67ca328a2a2e936a9807d
R
1,294
47
test_that("result of metagenomeSeq", { ps <- phyloseq::phyloseq( otu_table = otu_table( matrix( 1:12, nrow = 2, dimnames = list( c("feature1", "feature2"), paste0("sample", 1:6) ) ...
86de96343b913489c849a65b635e43bb1455ca34fa5b60fe751ffdadde4b7e66
R
1,299
36
## get data for ensemble summaries library(zoltr) ## devtools::install_github("reichlab/zoltr") library(tidyverse) theme_set(theme_bw()) ## load special functions source("code/processing-fxns/get_next_saturday.R") source("code/exploration/get_zoltar_PI.R") this_ensemble_timezero <- as.character(get_next_saturday(Sys...
a897419516b99daa7dc2cb93612a4a21664c19acb81f512f1420eb95ad9bccbf
R
1,365
53
ps <- phyloseq::phyloseq( otu_table = otu_table( matrix( sample(100, 40), nrow = 4, dimnames = list( paste0("otu", 1:4), paste0("sample", 1:10) ) ), taxa_are_rows = TRUE ), tax_table = tax_table( ...
2e3cf14139d158b29b8490a8b55f3d5f7852ac9492f9fdc77e0134fd71cd9074
R
1,366
41
#!/usr/bin/Rscript library(tidyverse) library(DescTools) library(igraph) library(ggnetwork) library(intergraph) args <- commandArgs(trailingOnly=TRUE) fi_cfg <- args[1] df_cfg <- read_tsv(fi_cfg) dio <- df_cfg %>% filter(key=="dir_out") %>% pull(value) str_cells <- df_cfg %>% filter(key=="cells") %>% pull(value) cel...
1c756a32205fee831d785d8b187b57e4e8c42f16c54a28149931869d2794cef1
R
1,386
50
library(readr) psm.file = list.files(pattern = '\\.psm\\.csv$')[1] psm = read_csv(psm.file) sequences = unique(gsub('[^A-Z]', '', psm$peptide)) sites = c('S', 'T', 'Y') lapply(sites, function(site) { peptides = do.call(rbind, lapply(sequences, function(sequence) { modifications = get.candidate.sites(sequence, '...
b22bfb4c8379978b212fc690e31c3b8791830cc011f5b49c32f18682802581c2
R
1,427
61
##### # utils old.repos <- getOption("repos") on.exit(options(repos = old.repos)) new.repos <- old.repos new.repos["CRAN"] <- "http://cran.stat.ucla.edu" options(repos = new.repos) source("http://www.bioconductor.org/biocLite.R") #if(!suppressMessages(require("BiocInstaller",quietly=T))){ # install.packages("BiocI...
46aa4e45e5d604fc826b7614bd3316eee69e2856131e0157ce2596ede5bf0ccf
R
1,459
49
get.modified.sequence = function(sequence, modification, symbol = c('Phospho' = '*', 'Oxidation' = '@')) { if (is.na(modification) || is.null(modification) || nchar(modification) == 0) { return(sequence) } s = strsplit(modification, ';')[[1]] name = gsub('[()]', '', stringr::str_extract(s, '\\(.+\\)$')) ...
8d277d0481450e71ec96d95c5d7604047d5c687d5cd6bf72897c9983e1ea7dbd
R
1,460
31
#' Getting some human readable PIs out of a Zoltar query #' #' @param data an object returned from a Zoltar query #' @param forecast_date a character interpretable as a date #' @param targets a list of valid targets for the project #' @param location a FIPS code #' @param alpha the alpha level of interest #' #' @return...
b4e630e37c745b0be0267e8d67f0f869a7098b923f587ae3ed810231b50c80be
R
1,495
51
library(data.table) setwd("E:/Work/ibs") save_zip = function(object,path){ fwrite(object,path) zip(paste0(path,".zip"),path) } grep_start = function(col,code){ grepl(paste0("^",code),col) } check_code = function(code,P,cols,col_prefix="has",starts_with=FALSE){ if((code=="") | is.na(code)){return(NULL)} ...
de91d4dae9cebb536bc620bb3410e6f55939bf79ac0eb9a84458ad890b4b2c28
R
1,516
45
data(enterotypes_arumugam) ps_t <- transform_abundances(enterotypes_arumugam, "log10p") otutable_t <- transform_abundances(otu_table(enterotypes_arumugam), "log10p") mm <- microbiomeMarker( marker_table = marker_table(data.frame( feature = c("speciesA", "speciesB"), enrich_group = c("groupA", "group...
8e18e87adc8b4eab9e292a1e4a61528eacd01f64746d29cf77bfb466d9190aa5
R
1,578
63
write.msp = function(spectra, file) { writeLines(sapply(spectra, function(x) { s = paste0('Name: ', x$peptide, '/', x$charge) if (!is.null(x$mw)) { s = c(s, paste0('MW: ', x$mw)) } if (!is.null(x$comment)) { comment = x$comment } else if (!is.null(x$fields)) { comment = ...
b5c5c5365fe45bf08a43cf264837211615e1510b7a82732478af6eae19523f74
R
1,583
61
--- title: "Hospitalization Model Forecaster Filtering" author: "[The COVID-19 Forecast Hub Team](https://covid19forecasthub.org/doc/)<br><br>https://covid19forecasthub.org/" date: "report generated `r Sys.Date()`" output: html_document: toc: false toc_float: collapsed: false smooth_scroll: false ...
8d61c239ed7b4ada348d5dbd727c9df2cea471564bc460a2492d9ec914457a12
R
1,611
41
library(data.table) #Load phenotype data and questionnaire field mappings D = fread("/home/cq/work/ibs/pheno/ukb39562.csv") #M = fread("/home/cq/work/ibs/resource/GAD7_PHD9_UKBBmaps.csv") M = fread("/home/cq/work/ibs/resource/IBS GWAS_ PHQ-9 , PHQ-12 and GAD-7 fields - Sheet1.csv") PHQ9_fields = M[questionnaire=="PHQ...
ccd2f5a3edca1b0de030b9e34cd451aeeac73e17ee3d49e616b1db9f3e471405
R
1,616
38
## script to download forecasts for a particular location library(zoltr) ## devtools::install_github("reichlab/zoltr") library(tidyverse) ## load special functions source("code/processing-fxns/get_next_saturday.R") ## connect to Zoltar, requires an account: ## https://docs.google.com/forms/d/1C7IEFbBEJ1JibG-svM5Xbn...
529198ed9535779fb0eb7755d1137c35aa5c6dd39b293d997ae39e005556361b
R
1,659
39
test_that("comparing da methods", { data(ecam) expect_error(compare_DA(ecam, "delivery", methods = c("test", "ancombc")), "methods test not available") }) test_that("flatten args",{ expect_error(generate_compare_args("lefse", list(a=1)), "does not match DA methods") a...
b55dbf2ca8df0eb1834c5f4eb02f153c4076e09c792d8f2716157492d7517df9
R
1,659
41
library(dplyr) library(ggplot2) library(data.table) setwd('/exports/igmm/eddie/GenScotDepression/shen/ActiveProject/ImagingProject/Adolescent_MDD_brain') load('result/x.Supplementary_materials/summ_ItemDiscre.RData') # Make proportion bar plot -------------------------------------------------------------------------...
e83b8e3c77fd69c6c78d7dd2073f738b7ff4d66cb9a6ccd72291d7ab7978e6cd
R
1,688
42
#' Extract top N US counties by size #' #' @param n_top number of counties to extract #' #' @return a data frame based on JHU CSSE data with info on population #' #' @examples get_filtered_counties <- function(n_top=100, include_US=TRUE) { require(tidyverse) fips_codes <- read_csv("data-locations/locations.csv"...
700dfd52384532f5d0db948f09a14488d467455af71113354d1d1218b5b32808
R
1,699
65
--- title: "Hospitalization Model Forecaster Filtering" author: "[The COVID-19 Forecast Hub Team](https://covid19forecasthub.org/doc/)<br><br>https://covid19forecasthub.org/" date: "report generated `r Sys.Date()`" output: html_document: toc: false toc_float: collapsed: false smooth_scrol...
62ef00410d6643089d9ba0224dd828b45ef75cc42e8b6db4108ba1e20d7e57c7
R
1,728
50
# 26th September # Reading in and printing results for Python Holstein Simulations # Update 27th Feb 2019 # Plotting both high- and low-N0 estimates # Update 1st Apr 2018 # Plotting separate high and low N0 figures # 11th Feb 2020 # Setting input samples to 204. # Function to turn log-log fit into actual function #...
bb100298e015fa8449c82a9dcca766c40a84aa6d4ce0317b34342ee1d83b599d
R
1,737
37
#' Summarize submission counts in each week for each model and each target #' #' @param submissions a data.frame with forecast dates, target and type for all forecasts #' @return a data.frame with a weekly count #' get_submissions = function (submissions){ submissions = reshape2::melt(submissions, ...
971911288d35d4d06dde1b06e25963c6fe8d7fd64b4f0c20988f8c62c37e6bf4
R
1,743
34
library(ggplot2) library(cowplot) library(data.table) theme_set(theme_cowplot()) setwd("~/work/ibs") R = readRDS("tables/R_for_natgen_rg_plot.rds") data_combos = c("Discovery cohort","Bellygenes data only","UK Biobank data only","Higher-specificity","Severe (IBS-SSS>300)") R = R[plot==TRUE & trait1 %in% data_combos] R[...
c48259fba2711527ea42390b8ad17a4780480042b40ff575087b41727135251a
R
1,761
57
#!/usr/bin/Rscript #Rscript script commonfile bamout #example: #Rscript bam2rdata.r /cluster/thashim/basepiq/common.r /cluster/thashim/basepiq/tmp/bams.RData /cluster/cwo/dnase_seq/bams/D0_50-100_130801.bwa.mapq20.mm10.bam options(echo=TRUE) args <- commandArgs(trailingOnly = TRUE) print(args) commonfile = args[1] ba...
a34faef246814155c9375b8bc3752633c5b2a645cd67ecd58f4084dd3b47249f
R
1,782
36
# Basic setups ------------------------------------------------------------ library('dplyr') library('pbapply') library('nlme') setwd('/exports/igmm/eddie/GenScotDepression/shen/ActiveProject/ImagingProject/ABCD_MDD_brain/') # Load data --------------------------------------------------------------- # fam dat...
a3cd59f5599fa20fc2d767cd642ca60b2b2e1d0b4cd24209e07939fb7efc86ea
R
1,817
47
library(dplyr) setwd('/gpfs/igmmfs01/eddie/GenScotDepression/shen/ActiveProject/ImagingProject/Adolescent_MDD_brain') tab.dat.dir='/exports/igmm/eddie/GenScotDepression/data/abcd/release2.0.1/iii.data' # merge and save the master file ---------------------------------------------------------------------- dir.var.l...
8d7c472baf81ef8fab746cb398e69085cc53f8a1c088d95f872311a216f41e44
R
1,830
47
# Items used # By XShen # 18/05/2020 # Settings ---------------------------------------------------------------- library('dplyr') library('ggplot2') library(reshape2) library(xlsx) setwd('Z:/Documents/sdata_backup/Shen/iv.ABCD/release2.0.1/FamilialRisk_PGRS_MDD') # Load data dictionary ------------------...
923f159e1355871651eec87bc36b958ef7dee66cb68735a962518df5c2890257
R
1,835
66
source('common.global.r') ##### # Check before running #minimum map quality mapq = -1 # load genome file suppressMessages(bis("BSgenome.Hsapiens.UCSC.hg19")) genome = BSgenome.Hsapiens.UCSC.hg19 ##### # Run mode options #if a file indicating completion is found; exit. overwrite=T #purity of calls purity.cut = 0.7 ...
5207d00b3dd1c42900c9650aae92db3065ef76f52beeed9f6602d9971fd33c2a
R
1,837
66
source('common.global.r') ##### # Check before running #minimum map quality mapq = -1 # load genome file suppressMessages(bis("BSgenome.Mmusculus.UCSC.mm10")) genome = BSgenome.Mmusculus.UCSC.mm10 ##### # Run mode options #if a file indicating completion is found; exit. overwrite=T #purity of calls purity.cut = 0....
361c8b790a4829cd834c28ff421b6a5c2491341b176d46b58b6f3109429e9fb8
R
1,846
66
#' Assign a new OTU table #' #' Assign a new OTU table in microbiomeMarker object #' @param x [`microbiomeMarker-class`] #' @param value [`otu_table-class`], [`phyloseq-class`], #' or [`microbiomeMarker-class`] #' @docType methods #' @name assign-otu_table #' @importMethodsFrom phyloseq otu_table<- #' @importClassesF...
0aacf80536b5ee5074e7256312951ab3c2cd7f09cab20124716f08f034b2f327
R
1,897
56
align.peaklists = function(peaklists, tolerance) { all.peaks.mz = unlist(sapply(peaklists, function(x) x[, 1])) all.peaks.int = unlist(sapply(peaklists, function(x) x[, 2])) all.peaks.from = unlist(sapply(1:length(peaklists), function(i) rep(i, nrow(peaklists[[i]])))) all.peaks.used = rep(FALSE, length(all.peak...
ba5a6ab8804efb86acd16aac4de8e017262f4322b4969caba2806a238ba19f40
R
1,929
65
data(enterotypes_arumugam) enterotype <- phyloseq::subset_samples( enterotypes_arumugam, Enterotype %in% c("Enterotype 3", "Enterotype 2", "Enterotype 1") ) tukey_res <- run_posthoc_test(enterotype, "Enterotype", method = "tukey") test_that("etaseq effect size", { etasq <- calc_etasq(c(1, 2, 1.2, 3, 4, 1....
ea1297292266c4680462c0d307d0c2ca0b95e20ba3e70fe88f62781625194f1f
R
1,935
59
#' Transform the taxa abundances in `otu_table` sample by sample #' #' Transform the taxa abundances in `otu_table` sample by sample, which means #' the counts of each sample will be transformed individually. #' #' @param object [`otu_table-class`], [`phyloseq-class`], or #' [`microbiomeMarker-class`]. #' @param tra...
f36bc6864f46dd6e9e90e62c9e4748922f8bba7bf44b11bb448582df9d385253
R
1,939
74
#!/usr/bin/Rscript library(tidyverse) library(reshape) library(huge) df2mat <- function(df){ df <- as.data.frame(df) colnames(df) <- c("x", "y", "z") ids <- sort(unique(c(as.character(df$x), as.character(df$y)))) mat <- matrix(NA, nrow=length(ids), ncol=length(ids), dimnames=list(ids, ids)) diag(mat) <- 1 ...
3358c024360d2b980ec45bf13b8ceee001d44687cb7159da5aedcfb7c9ca90fc
R
1,947
48
###### # by Shen library(dplyr) setwd('/exports/igmm/eddie/GenScotDepression/shen/SData/UKB/iv.ABCD/release2.0.1/FamilialRisk_PGRS_MDD/') tab.dat.dir='/exports/igmm/eddie/GenScotDepression/shen/SData/ABCD/release2.0.1/iii.data' # merge, QC and save the master file (FAM dat) ------------------------------------------...
f61eba3080af468aab3af0bba61ce122176298f10c466624fd485d84aae6dc39
R
1,948
57
#!/usr/bin/Rscript library(tidyverse) library(igraph) set.seed(1000) args <- commandArgs(trailingOnly=TRUE) dir_work <- args[1] cell <- args[2] dio <- file.path(dir_work, "07_cliques", cell) # Transcription factor, Transcription cofactor, Others, RNA binding protein, Chromatin remodeller, Nuclear enzyme, Polycomb ...
fdaed1b1823756a25d8e88ff3f5a06a9e7a0bd93b67728035280d649f2ec8a21
R
2,009
82
#!/usr/bin/Rscript #Rscript script common-path jaspar-dir id output #example: #Rscript pwmmatch.r /cluster/thashim/basepiq/common.r /cluster/thashim/basepiq/pwms/jaspar.txt 141 /cluster/thashim/basepiq/tmp/pwmout.RData options(echo=TRUE) args <- commandArgs(trailingOnly = TRUE) print(args) commonfile = args[1] bedin ...
6460696c80b35ec67b4e0a6d27f0667cedd3af2b23fa72cb7ef3ad5d5496d00e
R
2,075
63
lapply(list.files(pattern = '\\.pdeep2\\.mgf$'), function(mgf.file) { spectra = read.mgf(mgf.file) fragments = list( list('b+1', 'b1', nTerm = TRUE), list('b+2', 'b2', nTerm = TRUE), list('y+1', 'y1', nTerm = FALSE), list('y+2', 'y2', nTerm = FALSE), list('b+1-ModLoss', 'bp1', nTerm = TRUE), ...
4f0bfde4ea87a7b856b630166e8f7fff8075de9136e59a849ca73b2579770cb4
R
2,077
50
# Basic setups ------------------------------------------------------------ library(dplyr) setwd('/sdata/images/projects/UKBIOBANK/users/Shen/iv.ABCD/release2.0.1/FamilialRisk_PGRS_MDD') # Load data --------------------------------------------------------------- FAM.dat=readRDS('data/FamHistory_clean/FAM.dat_TwTri_...
4171a0d28b21889130382d11c7db130d5b3c57aba2e1b7afb26a31b1b8f9d7b7
R
2,111
35
library(dplyr) ksad=readRDS('/sdata/images/projects/UKBIOBANK/ABCD/release2.0/iii.data/Mental_Health/abcd_ksad01.rds') ksad.instance0=ksad[ksad$eventname=='baseline_year_1_arm_1',] ksad.instance1=ksad[ksad$eventname=='1_year_follow_up_y_arm_1',] MDD_lifetime.dat.ins0=data.frame(id=ksad.instance0$src_subject_id, ...
aad8b03adc472a10c2633146251b66ce7b89ba6ba5f0601beea4e1732b754981
R
2,116
64
# by Shen # 17/10/2020 # *result.table # *ls.vertical.vars= a vector of values in factor variable # *cols.select= cols to keep in the result table # *dep.kw: key word for dependent variable to select part of the result # *colheaders ##### Settings library(dplyr) ##### Main script reorg_result_web<-function(kw.combo....
50b4dec30b23ac2a983729cd9805b7dc6c1d9c6e68c6ade49c717a6dc8b85107
R
2,152
56
## R data validation For those familiar with R (but not python), there is a separate set of tests that **may** be useful to diagnose data formatting issues in [functions_plausibility.R](../code/validation/R-scripts/functions_plausibility.R). We have tried to keep these in sync with the python checks automatically ru...
7243738932f97a9f623a35df2f779e6b212f382e72048418323ae967d0366c68
R
2,159
80
test_that("microbiomeMarker constructor", { marker1 <- marker_table( data.frame( feature = paste0("sp", 1:5), enrich_group = c("cr", "er", "cr", "cr", "er"), stringsAsFactors = FALSE ) ) marker2 <- marker_table( data.frame( feature = pa...
0db64436d5b938f77c8ef0a4f97c9585836e9572fafe11e2fef76c3f308ae32a
R
2,265
55
#' Combine all truth files #' #' @param inc_jhu jhu inc data.frame #' @param inc_usa usa inc data.frame #' @param inc_nyt nyt inc data.frame #' @param cum_jhu jhu cum data.frame #' @param cum_usa usa cum data.frame #' @param cum_nyt nyt cum data.frame #' @param inc_cases_nyt nyt case inc data.frame #' @param inc_cases...
b35bdff9d7256d582688e153bcf1a99b2461a45d7b2aa6231107b99f131d2bb1
R
2,274
50
setwd('Z:/Documents/sdata_backup/Shen/iv.ABCD/release2.0.1/AdolescentMDD/') source('FUNs/PheWAS_style_p_plot.R') source('FUNs/wholeB_correction.R') # Settings load('result/i.Main_result/YouthDepree_WM_subcor_FS_noSocialCov.RData') # Preprocess results object ----------------------------------------------- ...
e5143dc72e0d4de6dafe9df2abab7a2d62cc7fd952a11216bedec998afe79948
R
2,276
42
targetdata=targetdata[!is.na(targetdata$KSADS.MDD.p)&!is.na(targetdata$KSADS.Depressive_symptoms_ever.p)& !is.na(targetdata$depression_family_noManiaVision)& !is.na(targetdata$depression_bioFather_noManiaVision)& !is.na(targetdata$depre...
9a3efde89e0ae76b9b4a9af5992a13e561488279394b6151fcc4438ca9a66594
R
2,292
94
#!/usr/bin/Rscript #Rscript script commondir pwmdir tmpdir outdir bamfile pwmid #example: #Rscript pertf.r /cluster/thashim/basepiq/common.r /cluster/thashim/tmppiq/ /scratch/tmp/ /cluster/thashim/130130.mm10.d0/ /cluster/thashim/tmppiq/d0.RData 139 options(echo=TRUE) args <- commandArgs(trailingOnly = TRUE) print(arg...
9fdfcdf5afbec6408a9f0662219d348878696ae76799d2d7a98235114c9b9f59
R
2,299
60
#' Plotting DA comparing result #' #' @param x an `compareDA` object, output from [`compare_DA()`]. #' @param sort character string specifying sort method. Possibilities are #' "score" which is calculated as \eqn{(auc - 0.5) * power - fdr}, "auc" for #' area under the ROC curve, "fpr" for false positive rate, "powe...
ef8e7fddb8741db22e684f2ef54035aa68e3344f34c2d0e166612c33d49ad8c4
R
2,308
58
setwd('Z:/Documents/sdata_backup/Shen/iv.ABCD/release2.0.1/FamilialRisk_PGRS_MDD') source('FUNs/PheWAS_style_p_plot.R') source('FUNs/wholeB_correction.R') # Settings load('result/x.Supplementary_materials/FAMrisk_asr_WM_FS.RData') ls.category=read.table('data/p_plot_dat/ls.category.txt',header=F,stringsAsFactors = F,...
64554f352072b49201551d99b6e2dc80fd8a66c4d411458e627863ac0d214b51
R
2,339
58
setwd('Z:/Documents/sdata_backup/Shen/iv.ABCD/release2.0.1/FamilialRisk_PGRS_MDD') source('FUNs/PheWAS_style_p_plot.R') source('FUNs/wholeB_correction.R') # Settings load('result/i.Main_result/famRisk_noSocialCov.RData') ls.category=read.table('data/p_plot_dat/ls.category.txt',header=F,stringsAsFactors = F,sep = '\t'...
b176e86c1bc9a97492b5a49ec4f2ff5b1b23d53ff5d51c5cbb6b5caf89518952
R
2,364
97
#!/usr/bin/Rscript #Rscript script commondir pwmdir tmpdir outdir bamfile pwmid #example: #Rscript pertf.r /cluster/thashim/basepiq/common.r /cluster/thashim/tmppiq/ /scratch/tmp/ /cluster/thashim/130130.mm10.d0/ /cluster/thashim/tmppiq/d0.RData 139 options(echo=TRUE) args <- commandArgs(trailingOnly = TRUE) print(arg...
836dbd739e3fc24f6832fbcd39bb51b450b21b35620eb87e66d66afcec8b7481
R
2,366
68
library(XML) library(readr) psm.file = list.files(pattern = '\\.psm\\.csv$')[1] psm = read_csv(psm.file) activationTypes = 'HCD' massTolerance = 0.02 scoreNeutralLoss = FALSE spectra.file = '' spectra = NULL spectrumTitle = NULL spectraNode = newXMLNode('Spectra', lapply(1:nrow(psm), function(i) { file = paste0(ps...
572244b6e308318ae081565e756008be9e05097bb67d862385207224dfe86024
R
2,397
58
setwd('Z:/Documents/sdata_backup/Shen/iv.ABCD/release2.0.1/FamilialRisk_PGRS_MDD') source('FUNs/PheWAS_style_p_plot.R') source('FUNs/wholeB_correction.R') # Settings load('result/i.Main_result/famRisk_noSocialCov.RData') ls.category=read.table('data/p_plot_dat/ls.category.txt',header=F,stringsAsFactors = F,sep...
0e9f36de034eed9fe8df61d51447d4487f9da1bc625e1326bc5b19244d1fa1a9
R
2,501
88
ions.to.spectra = function(ions, carbamidomethyl = TRUE, charge = NA, ...) { lapply(ions, function(x) { if (is.null(x$charge)) { x$charge = charge } mz = fragment.ions.mz.1( x$peptide, modification = x$modification, type = c('b', 'y'), charge = c(1, 2), loss = c('...
111ae013c8753086fa03d36cdada51ef94c689d825878c76de812e99f56015ab
R
2,504
68
## reference # https://github.com/biomedbigdata/namco/blob/647d3108a281eb0e36af31c44f5bf38d0c70c07d/app/R/utils.R#L480-L561 # https://github.com/biomedbigdata/namco/blob/647d3108a281eb0e36af31c44f5bf38d0c70c07d/app/R/server/confounding_server.R#L71-L100 # vagan: https://fromthebottomoftheheap.net/slides/advanced-vegan-...
9dcad503c36e95c1bb5d31a329f360e0f99828025391ccaae6d5373723c2cb8f
R
2,508
103
#!/usr/bin/Rscript #Rscript script commondir pwmdir tmpdir outdir bamfile pwmid #example: #Rscript pertf.r /cluster/thashim/basepiq/common.r /cluster/thashim/tmppiq/ /scratch/tmp/ /cluster/thashim/130130.mm10.d0/ /cluster/thashim/tmppiq/d0.RData 139 options(echo=TRUE) args <- commandArgs(trailingOnly = TRUE) print(arg...
65510e9e9cc8de81c6546a0339d64ac11c33f56479892d1bff378504c0d468e0
R
2,522
83
library(data.table) setwd("~/work/ibs") library(coloc) meta_dataset = function(meta_path){ SS = fread(meta_path) SS = SS[nchar(SNP)>=1] s = median(SS$N_CASE)/median(SS$N_TOTAL) SS = SS[,.(snp=SNP, pvalues=`P-value`, beta=Effect, varbeta=StdErr^2)] #Should MAF be min(MAF,1-MAF)? dataset = list(type="cc", ...
cddd3e336b788d40bc242cc237343f190ca98b05b1add9464dfbdc374246e513
R
2,536
90
#' plot the abundances of markers #' #' @inheritParams plot_ef_bar #' @param group character, the variable to set the group #' @return a [`ggplot2::ggplot`] object. #' @importFrom ggplot2 ggplot aes geom_boxplot theme_bw element_text #' @export #' @examples #' data(enterotypes_arumugam) #' mm <- run_limma_voom( #' ...
71a591bb07f5ecfe9d91c55f31f1f1928cdaed5accf37419ff1ad4bec44dc058
R
2,558
104
#!/usr/bin/Rscript #Rscript script commondir pwmdir tmpdir outdir bamfile pwmid #example: #Rscript pertf.r /cluster/thashim/basepiq/common.r /cluster/thashim/tmppiq/ /scratch/tmp/ /cluster/thashim/130130.mm10.d0/ /cluster/thashim/tmppiq/d0.RData 139 options(echo=TRUE) args <- commandArgs(trailingOnly = TRUE) print(arg...
741d020c453fa2b5c7315eb1447d3df8b5eedf0c552616d7888bc6b93202d5d8
R
2,577
100
#' ROC curve of microbiome marker from supervised learning methods #' #' Show the ROC curve of the microbiome marker calculated by `run_sl`. #' #' @param mm a [microbiomeMarker-class] object. #' @param group,nfolds,nrepeats,tune_length,... same with the `run_sl()`. #' #' @importFrom plotROC geom_roc style_roc calc_auc ...
425e6837f6b5474cb8ab672436e2b615cbb79f8737085fc0347f1bdc070c12c9
R
2,633
72
setwd('Z:/Documents/sdata_backup/Shen/iv.ABCD/release2.0.1/AdolescentMDD/') source('FUNs/PheWAS_style_p_plot.R') source('FUNs/wholeB_correction.R') # Settings load('result/x.Supplementary_materials/YouthDepree_QCcomparison_DTI.RData') res.1=result.YouthDepre.region.covWholeB.all res.2=result.YouthDepre.region.covWhol...
4b0a7eb762ac4a768dd2dc57a92b925aa99c6e2accfa9a80aba1f0bf64465399
R
2,678
97
library(gplots) library(archetypes) library(ggplot2) ############# archetype (n=3 archetypes) Parameters=read.table(file="betaphykap.txt") #### beta phy kapp for n=82 mice (55 Ctl mice and 27 nic mice) Dataall=read.table(file="alldata.txt") #### parameters for n=82 mice set.seed(1625) as <- stepArchetypes(d...
ded3a2187a67a37b5c4fe1079443fd3ef12e5e470d128832fe4488090c71b476
R
2,679
92
library(lubridate) library(DT) library(zoltr) ## devtools::install_github("reichlab/zoltr") library(scico) source("../processing-fxns/get_next_saturday.R") library(tidyverse) library(htmltools) library(covidHubUtils) theme_set(theme_bw()) # new libraries library(crosstalk) library(plotly) # parallelizin...
7ba81a89d848dec81b0c3885354a66cb1449f82c2e19f2e4748532d99cbfdb88
R
2,683
67
# Read in all the forecast files in data-processed/ library("dplyr") library("tidyr") library("readr") read_my_csv = function(f, into) { tryCatch( readr::read_csv(f, col_types = readr::cols_only( forecast_date = readr::col_date(format = ""), targ...
5de7612939f4e19456638c33d4832d1fe5da29d1586635f2070fa312af3f8083
R
2,698
92
library(lubridate) library(DT) library(zoltr) ## devtools::install_github("reichlab/zoltr") library(scico) source("../processing-fxns/get_next_saturday.R") library(tidyverse) library(htmltools) library(covidHubUtils) theme_set(theme_bw()) # new libraries library(crosstalk) library(plotly) # parallelizin...
b6fd282ed3b9a98e805ccad99b85d538b051c926682e248ffbdbdd584dc94d1e
R
2,762
92
# This function is inspired from microbiome::abundances #' Extract taxa abundances #' #' Extract taxa abundances from phyloseq objects. #' #' @param object [`otu_table-class`], [`phyloseq-class`], or #' [`microbiomeMarker-class`]. #' @param transform transformation to apply, the options inclulde: #' * "identity", re...
0c9beee2ea32a601bbcc37afdee95ac22d4f0f71b80ca4905eda2e589d67a3bc
R
2,775
89
library(tidyverse) library(covidData) library(here) setwd(here()) most_recent_sunday <- lubridate::floor_date(Sys.Date(), unit = "week") # plot death outliers for (measure in c("cases", "deaths", "hosps")) { outliers <- readr::read_csv( paste0("data-anomalies/outliers-inc-", measure, ".csv") ) ...
e876e0d5ea6b308ece399678c8e0ab0cb4501547edad2512b6c1e745ef9ec9fc
R
2,859
81
read.msp = function(file) { lines = readLines(file) begin.indexs = grep(pattern = '^Name: ', x = lines) end.indexs = c(begin.indexs[-1] - 1, length(lines)) lapply(1:length(begin.indexs), function(i) { internal.lines = lines[begin.indexs[i]:end.indexs[i]] internal.lines = internal.lines[nchar(internal...
3eeddfeb36f65c90514854573810991a080f447308ea48ed0aec8f9e9835ec4d
R
2,902
72
DESeqDataSetFromIRFinder = function(filePaths,designMatrix,designFormula,irratio_thr=0, warning_filter="^$" ){ res=c() libsz=c() spl=c() irtest=read.table(filePaths[1]) if (irtest[1,1]=="Chr"){irtest=irtest[-1,]} irnames=unname(apply(as.matrix(irtest),1,FUN=function(x){return(paste0(x[4],"/",x[1...
079c14205d2852fa4f35a9c1c4d553d098b7293fca601dae8f417d77c55853cc
R
2,919
97
library(readr) lapply(list.files(pattern = '\\.ms2pip\\.csv$'), function(ms2pip.file) { ms2pip = read_csv(ms2pip.file) psm.indexes = which(sapply(1:nrow(ms2pip), function(i) { if (i == 1) { return(TRUE) } if (ms2pip$spec_id[i] != ms2pip$spec_id[i - 1]) { TRUE } else { F...
c625a559be4fb8c98a84f41c37e66dbc8624ccce7b117e14d56d115e3ee8f8f9
R
2,924
99
ions.to.spectra.loss = function(ions, carbamidomethyl = TRUE, charge = NA, lossRatio = 0.9, ...) { lapply(ions, function(x) { if (is.null(x$charge)) { x$charge = charge } mz = fragment.ions.mz.1( x$peptide, modification = x$modification, type = c('b', 'y'), charge = c(1,...
5b3fd23515c26b94a49c456f6eb5fc4ccf879c134e6ed6d08989a27d4531f7ef
R
2,932
89
#!/usr/bin/Rscript #Rscript script commonfile bamout #example: #Rscript bam2rdata.r /cluster/thashim/basepiq/common.r /cluster/thashim/basepiq/tmp/bams.RData /cluster/cwo/dnase_seq/bams/D0_50-100_130801.bwa.mapq20.mm10.bam options(echo=TRUE) args <- commandArgs(trailingOnly = TRUE) print(args) commonfile = args[1] ba...
ab2ee64bb58638b559f1a928c16aa9a3eff9daf27c0903c62dd85368086017f8
R
2,938
76
setwd('Z:/Documents/sdata_backup/Shen/iv.ABCD/release2.0.1/FamilialRisk_PGRS_MDD') source('FUNs/PheWAS_style_p_plot.R') source('FUNs/wholeB_correction.R') # Settings load('result/x.Supplementary_materials/YouthDepree_WM_subcor_FS_harshQC.RData') res.1=result.YouthDepre.region.covWholeB load('result/i.Main_result/Yout...
7b737ee82abcd4750db34b291ec445186b6c9659171fe55cc9fde65b4581a020
R
2,965
82
# This function is modified from import_dada2.R in MicrobiotaProcess # https://github.com/YuLab-SMU/MicrobiotaProcess/blob/master/R/import_dada2.R #' Import function to read the the output of dada2 as phyloseq object #' #' Import the output of dada2 into phyloseq object #' #' @param seq_tab matrix-like, ASV table, the...
7c9dcc011a62ed068369623e5107aa8feebcdf2ddf4708aa18d73ee99dbbaf57
R
2,986
80
#' @title Import function to read the tab-delimited input file of biobakery #' lefse #' #' @description For biobakey lefse, the input file must be a tab-delimited #' text, consists of a list of numerical features, the class vector and #' optionally the subclass and subject vectors. The features can be read counts #' di...
8167aa135dff8cb78783981eac6885812736ab4dcc9a278b33947cf1e9db590f
R
3,033
76
setwd('Z:/Documents/sdata_backup/Shen/iv.ABCD/release2.0.1/FamilialRisk_PGRS_MDD') source('FUNs/PheWAS_style_p_plot.R') source('FUNs/wholeB_correction.R') # Settings load('result/x.Supplementary_materials/YouthDepree_QCcomparison_DTI.RData') res.1=result.YouthDepre.region.covWholeB load('result/i.Main_result/...
4dc70e34caf848f18ab4d7797af29633d7efea2495313110818185216f8a2ac3
R
3,047
76
setwd('Z:/Documents/sdata_backup/Shen/iv.ABCD/release2.0.1/AdolescentMDD/') source('FUNs/PheWAS_style_p_plot.R') source('FUNs/wholeB_correction.R') # Settings load('result/x.Supplementary_materials/YouthDepree_WM_subcor_FS_covParentDepre.RData') res.1=result.YouthDepre.region.covWholeB load('result/i.Main_res...
a047dcec6e16135821522dcd2d06807959c63e02746240a809ec6ce78487d4f6
R
3,092
77
setwd('Z:/Documents/sdata_backup/Shen/iv.ABCD/release2.0.1/AdolescentMDD/') library(dplyr) library(ggplot2) source('FUNs/PheWAS_style_p_plot.R') source('FUNs/wholeB_correction.R') # Settings load('result/x.Supplementary_materials/YouthDepree_WM_subcor_FS_noAge2.RData') res.1=result.YouthDepre.region.covWholeB ...
0462a244a740d5eaec1ae45f595aa8c26a35a796dc67d22b25bbb05b3679d301
R
3,108
75
# Download and format nytimes data # Jarad Niemi # May 2020 library("readr") library("dplyr") us_url <- "https://raw.githubusercontent.com/nytimes/covid-19-data/master/us.csv" states_url <- "https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-states.csv" counties_url <- "https://raw.githubuserconten...
b2cb7437bc8e300aebeda1b45d58a4d3ec69ec8c21bea5e8e6e2804e0b293d94
R
3,122
74
setwd('Z:/Documents/sdata_backup/Shen/iv.ABCD/release2.0.1/AdolescentMDD/') source('FUNs/PheWAS_style_p_plot.R') source('FUNs/wholeB_correction.R') # Settings load('result/x.Supplementary_materials/YouthDepree_WM_FS_covMedication.RData') res.1=result.YouthDepre.region.covWholeB load('result/i.Main_result/Yout...
56366675b00df0b400a068f5c701c826937d158275ecaaf3e057510e980384ad
R
3,130
74
setwd('/gpfs/igmmfs01/eddie/GenScotDepression/shen/ActiveProject/ImagingProject/Adolescent_MDD_brain') source('FUNs/PheWAS_style_p_plot.R') source('FUNs/wholeB_correction.R') # Settings load('result/x.Supplementary_materials/meanYouthDepree_WM_subcor_FS_noSocialCov.RData') res.1=result.YouthDepre.region.covWho...
95aa750e06c8b9e3352b2e11b864f726c47b61c666ed01a1a67a6e517c055e53
R
3,130
104
ions.to.spectra.budding = function(ions, carbamidomethyl = TRUE, charge = NA, budding = 5e-3, budding.type = c('b', 'y', 'bp', 'yp'), budding.charge = c(1, 2), ...) { lapply(ions, function(x) { if (is.null(x$charge)) { x$charge = charge } mz = fragment.ions.mz.1( x$peptide, modifica...
e995fbf3e279b83a8cbece3d0a69f3e35fc6d1959a3d79f152c7535bc774599d
R
3,137
95
test_that("ancombc works correctly", { if (FALSE) { # result of ancombc package, example from the package vignette # atalas1006 from microbiome package pseq <- subset_samples(atlas1006, time == 0) sample_data(pseq)$bmi_group <- recode( sample_data(pseq)$bmi_group, ...