sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
524133cc5987c8974527bcee239584fb7944bcb9c44e8abb42ee59993ca94c01 | Python | 36,733 | 961 | #!/usr/bin/env python
"""
Utility for visualizing quality of peak finding.
Hazen 05/13
main
"""
import numpy
import os
import sys
from functools import partial
import shutil
import glob
import numpy as np
from qtmodern import styles
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidge... |
e72416a735cdc1c8220e24072db1418b7199692c59133af366619bada230625d | Python | 36,795 | 891 | from __future__ import print_function
import argparse
import codecs
import math
import multiprocessing
import os
import pickle
import shutil
from itertools import count
import torch
import onmt.decoders.ensemble
import onmt.inputters as inputters
import onmt.model_builder
import onmt.myutils as myutils
import onmt.o... |
f9676b7ba12f90aa6519b61d0643c7c2cf5ac32c62eb56cdaa61c461bb3d955f | Python | 36,974 | 1,202 | # Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... |
e9af76bf2789188a87d078821e65f4f348a0d4af3ac9e06c904c460ed7decabf | Python | 37,406 | 887 | # module imports
import copy
import functools
import numpy as np
# pyqt5 module import
from PyQt5.QtCore import QRect, Qt
from PyQt5.QtWidgets import (QCheckBox, QDialog, QHBoxLayout, QPushButton, QGridLayout, QGroupBox)
# custom module import
import analysis_guis.common_func as cf
import analysis_guis.rot... |
889b2a1415e99bde5d1191fc56be9b3e3827f2ad74368196a876b78587dc77f5 | Python | 37,871 | 819 | # coding=utf-8
# Copyright 2026 The Edward2 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... |
8a29fdb5147a826910afe755dcdf7dd997c88298249406382407b32b2308fa0c | Python | 38,290 | 1,097 | # coding=utf-8
# @license
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... |
48a7dfeeb0dad818a848a2196e941f1fb18edab7a857973b993c1d7603d0c76c | Python | 39,384 | 991 | import os
import sys
from collections import OrderedDict as ODict
from math import floor
from copy import copy, deepcopy
import shutil
import errno
import matplotlib
import numpy as np
from cached_property import cached_property
from scipy import stats
from experiment_resampler import ExperimentResampler
from plotti... |
b9f56ef1018be7747dec96193c9a7f20a14385af11aecd273d1fe01cd0c556e6 | Python | 39,672 | 1,060 | #!/usr/bin/env python
"""
A ctypes based interface to Hamamatsu cameras.
(tested on a sCMOS Flash 4.0).
The documentation is a little confusing to me on this subject..
I used c_int32 when this is explicitly specified, otherwise I use c_int.
Hazen 10/13
George 11/17 - Updated for SDK4 and to allow fixed len... |
0db20a41f7f13202e089cbc573937818957439ea59bfb40c51fe17d32e7912f5 | Python | 40,219 | 1,003 | # module import
import os
import re
import copy
import time
import platform
import pickle as p
import numpy as np
# pyqt5 module imports
from PyQt5.QtCore import Qt, QRect
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import (QHBoxLayout, QDialog, QFormLayout, QPushButton, QGridLayout, QGroupBox,
... |
a2f3fffb369422e40ea131c39b8f61dab67887921047c7ca1458c07e2700fee4 | Python | 42,471 | 1,361 | # Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... |
6f0bd5f20117bf4a5302b34a65f08a0b5fffa22e578b486ffc3627e39ea1b127 | Python | 42,538 | 1,196 | # Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... |
21cc8d4efc355825f5179b5e9e91d9b24eafe7dbf1f6699b8b04d048453f886c | Python | 43,709 | 1,091 | #!/cluster/software/bin/python3
import subprocess
import locale
import gzip
import sys
import re
import os
import csv
import requests
from pathlib import Path
from io import StringIO
from datetime import datetime, UTC
# priorities derived from the 'Monthly usage stats' report
# from the qateam cron job running on the... |
f360b5c2537cbc1096c8f70b4622e400eb2d5dc6db1a5ab77cbe052ec61b1876 | Python | 43,897 | 1,058 | """Test the functions in yasa/detection.py."""
import copy
import inspect
import logging
from contextlib import contextmanager
from types import SimpleNamespace
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pytest
from scipy.stats import hmean
from yasa._validation import _check_data_... |
8b65aa15fd98a39e9c75123b5d308b76cbe0c9622ac705fbdac6259e4dfed9cf | Python | 44,614 | 996 | import os
import numpy as np
import matplotlib.pyplot as plt
import cv2
import h5py
import pandas as pd
import pickle
import time
from scipy.signal import savgol_filter, find_peaks
import scipy.stats
import sys
import matplotlib
matplotlib.rcParams['font.size'] = 12
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib... |
3fc017630e45d639bff02442aa30949401733509c057506d8336ceaa4502ebc4 | Python | 44,828 | 1,390 | from typing import Sequence
import numpy as np
import pytest
import tifffile
import torch
from brainglobe_utils.cells.cells import Cell, file_name_from_cell
from pytest_mock.plugin import MockerFixture
from torch.utils.data import DataLoader
from cellfinder.core.classify.cube_generator import (
BaseImage,
Cac... |
f631392703ae42259b34639240373ea05e117623b0cbb5206efa77204fad514a | Python | 46,495 | 1,402 | from biodblinker import KEGGLinker, SiderLinker, MESHLinker
from os import makedirs, listdir, remove, walk
from os.path import join, isdir
from shutil import copy
import gzip
kegg_linker = KEGGLinker()
sider_linker = SiderLinker()
mesh_linker = MESHLinker()
data_root = 'data/preprocessed'
output_root = 'data/output'
... |
b37cfaf600e72f3486af6431ed825df581a7ae6501c006a22bba2fd004b05455 | Python | 46,652 | 940 | import numpy as np
import sys
import os
import pathlib
import sys
import h5py
from PIL import Image
from .corr_mols_v8 import corr_mols
import skimage
import skimage.transform
from skimage.transform import (estimate_transform)
import matplotlib.pyplot as plt
import yaml
import tifffile as timg;
from tifffile impor... |
1403b3d198226702bbe11624db6b5e16621573e980561d039b197e12ece168a8 | Python | 46,746 | 864 | #!/usr/bin/env python
# coding: utf-8
from bokeh.models.widgets import Select
from bokeh.layouts import column, row, Spacer
from bokeh.plotting import figure, curdoc
# from bokeh.io import output_notebook, push_notebook, show #unused import
from bokeh.models.annotations import Span, ColorBar
from bokeh.models.widgets ... |
82df54b1b680b043dd5b1234959b49491e936cf63723a103fec19777cccda9b0 | Python | 48,559 | 1,136 | # Created by woochanghwang at 21/05/2020
# Modified by woochanghwang at 12/07/2020
# Modified at 18/07/2020
# Modified at 19/07/2021 for Method paper
'''
Make input files for CIRCUS
including selected drug targets in the network, key genes
# Modified by woochanghwang at 21/07/2020
- Hidden enrichment test (High level p... |
6a88cc4f677b65970f936a8aa4f3ecc0a350c81c1b57bb94915bba01bd549bb4 | Python | 51,753 | 1,548 | # originally from https://github.com/tryolabs/luminoth/blob/master/luminoth/models/fasterrcnn/
import io
import numpy as np
import os
import logging
import PIL.Image as Image
import PIL.ImageDraw as ImageDraw
import PIL.ImageFont as ImageFont
import tensorflow as tf
import random
from .bbox_transform_tf import decode,... |
9d8d1f813195bc38581b01f9b066c60319ad22c1d4854a74f3eebbfd866aaead | Python | 52,639 | 1,337 | # coding=utf-8
# Copyright 2026 The Edward2 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... |
84ec1ea85648ae354dbc546761d1a3023e13a219bf1a0369f08f60a1c3f2a20c | Python | 56,519 | 1,446 | import math
from collections import OrderedDict, defaultdict
from collections.abc import Sequence
from numbers import Integral
from typing import Any, Hashable, Literal
import numpy as np
import torch
import torch.multiprocessing as mp
import torch.nn.functional as F
from brainglobe_utils.cells.cells import Cell
from ... |
888fc31c10969fc36dffea58681b80993c1ea34969adbfd5284be864837dbd7a | Python | 57,789 | 1,514 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 04 10:04:04 2021
@author: Florian Rückerl
"""
# =============================================================================
# Script to analyze IMARIS data from two-photon imaging (PSD95-venus and Alexa594 cell body)
# for the article:
#
# *Devel... |
d2fa7af03b0cb047cf595de8ed97bc9c632dca6114c12e9b9456af53110f674c | Python | 65,116 | 1,247 | import datetime
import os
import webbrowser
import torch.cuda
import wx
from .runner_for_ui import (
search_pretrain_params,
check_ui_config,
fillin_runner_cmd_from_ui_config,
CMDRunnerThread,
BuildLibThread,
MergeLibThread
)
from .ui_configs import *
# Define params in UI
PipelineParams = {
... |
d8d099cbf97e26559fc1febfd1e6705f67feba16648fa2425634a4d63c2ad9e0 | Python | 69,679 | 1,532 | # module import
import copy
import peakutils
import math as m
import numpy as np
import pandas as pd
from random import random as rnd
from datetime import datetime
from dateutil import parser
from collections import OrderedDict
# custom module import
import analysis_guis.common_func as cf
from pyphys.pyph... |
4bbe1f33597e5a2e26a725273347df9e105bf4cb5dcca97b0fe360f150f3d686 | Python | 86,096 | 2,428 | # -*- coding: utf-8 -*-
# @Author: Weiyue Ji
# @Date: 2020-09-09 04:01:25
# @Last Modified by: Weiyue Ji
# @Last Modified time: 2021-10-10 21:49:31
import os, matplotlib, math
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.colors import BoundaryNorm
from matplotlib.ticker import ... |
0e141669e1bf0b744330115ef257e7ce6cff74cd2d4656cee11c8703d6d1806f | Python | 87,084 | 2,270 | # -*- coding: utf-8 -*-
"""
A collections of helper functions to work with dataset.
Load benchmark dataset, save and restore model, save and load variables.
TensorFlow provides ``.ckpt`` file format to save and restore the models, while
we suggest to use standard python file format ``.npz`` to save models for the
sake... |
ab63736d85fea30207026ff30ec539e413e3ce7166e088fbac7b716bff81ecf4 | Python | 88,048 | 2,147 | # coding=utf-8
# Copyright 2026 The Edward2 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... |
26b3b87ece2b6e3d7e7bf189dd7d4d892c6c8805b274f28e30967b88ef8b579b | Python | 88,643 | 2,261 | # coding=utf-8
# Copyright 2026 The Edward2 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... |
86ec028cf5896ade46d45be261812a43ad3a5f72b06867ef5cdc14be82b2dd20 | Python | 89,733 | 1,859 | """Tests for yasa/evaluation.py — EpochByEpochAgreement and SleepStatsAgreement."""
import re
import warnings
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pytest
import scipy.stats as sps
import sklearn.metrics as skm
from matplotlib.colors import to_rgb
from sklearn.exceptions import... |
1343f934002a5c7d67916f50b85f661a236838697af069f262037c76df423f2a | Python | 98,467 | 1,832 | #!/usr/bin/env python
# coding: utf-8
"""
This file is part of MADIP: Molecular Atlas Data Integration Pipeline
This module loads the data for step_1_collect_protein_data.ipynb jupyter notebook.
Age in days is only approximate and not involved in the downstream analysis. Qualitative age category is defined based on th... |
19140e79402d0b5956905b5848e878298a407459405ed4b21d07354217b29d5a | Python | 112,980 | 3,653 | # module import
import os
import re
import sys
import copy
import functools
import math as m
import numpy as np
import pandas as pd
import pickle as p
import seaborn as sns
from numpy import ndarray
from skimage import measure
from numpy.matlib import repmat
import matplotlib.pyplot as plt
from fuzzywuzz... |
59b843360c32a17d58ec06eb60b4a97d86a9e1bb05709d0be49312a29a41246a | Python | 124,047 | 2,960 | """
Hypnogram-related functions and class.
"""
import datetime
import logging
import warnings
import mne
import numpy as np
import pandas as pd
from pandas.api.types import CategoricalDtype
from .io import _restore_log_level
__all__ = [
"Hypnogram",
"load_profusion_hypno",
"hypno_str_to_int",
"hypno... |
dd5e80d76957d33fbd7c5d93d9b9bc91971379078e8c2119b888efd75296eb5a | Python | 125,549 | 3,344 | # -*- coding: utf-8 -*-
import gzip
import re
import requests
import time
from os.path import join
from ..util.extras import *
from timeit import default_timer as timer
import xml.etree.ElementTree as ET
from zipfile import ZipFile
from collections import defaultdict
import pandas as pd
P_UNIPROT_CODE = re.compile("[O... |
0d76f7917bb22bb8ec9bc65567e599dad877f53b7eb95e338e104b37d62958d5 | Python | 132,853 | 3,098 | """
YASA (Yet Another Spindle Algorithm): fast and robust detection of spindles,
slow-waves, and rapid eye movements from sleep EEG recordings.
- Author: Raphael Vallat (www.raphaelvallat.com)
- GitHub: https://github.com/raphaelvallat/yasa
- License: BSD 3-Clause License
"""
import logging
import types
from itertool... |
27c453b6d56f07f9d1edbed13557ff500b593c5e78b763205c1ac822e9c8b0c1 | Python | 159,687 | 5,495 | # Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... |
9b770db68195309445849bbda47ac9543a8364f7f5d89473d269accfe0c79fbd | Python | 162,739 | 4,476 | # module import
import os
import pywt
import copy
import random
import peakutils
import math as m
import numpy as np
import pickle as _p
import pandas as pd
from fastdtw import fastdtw
import scikit_posthocs as sp
from numpy.matlib import repmat
import shapely.geometry as geom
# scipy module imports
fr... |
2ba29025762465e3818e252b2a9e50004666686c56670d34768ec6483b664520 | Python | 173,470 | 3,368 | """
YASA code for evaluating the agreement between two scorers (e.g., human vs YASA), either at the
epoch-by-epoch level or at the level of summary sleep statistics.
Analyses are influenced by the standardized framework proposed in Menghini et al., 2021, SLEEP.
See the following resources:
- https://doi.org/10.1093/sl... |
1f49dcd44b691b7ab9f2253654ba37c2a986513bb6ae5a7377288bddb58345fa | Python | 200,000 | 4,440 | # module import
import os
import re
import time
import copy
import warnings
import datetime
import functools
import math as m
import xlsxwriter
import pickle as p
import numpy as np
import pandas as pd
from venn import venn
from random import sample
from numpy.matlib import repmat
from mpldatacursor imp... |
7e9dd04b083beecfc8dd8ea505f6369cbd50a0e227301429f665d9154ae11909 | Python | 200,000 | 4,148 | # module import
import gc
import os
import copy
import random
import platform
import numpy as np
import pickle as p
import pandas as pd
import multiprocessing as mp
from numpy.matlib import repmat
# scipy module imports
from scipy.stats import norm, linregress
from scipy.spatial.distance import *
from s... |
9204658d42fd824a3469739b1a17d21b5c660a8c62b7b0e296ee0fed51174b81 | Python | 200,000 | 5,885 | # Generated by the protocol buffer compiler. DO NOT EDIT!
# source: caffe.proto
import sys
_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1"))
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message ... |
c94737a167b0785701ef2f19acd5886d73320187075b5985aec6090719a14ae4 | R | 76 | 4 | library(testthat)
library(microbiomeMarker)
test_check("microbiomeMarker")
|
18f92786f6941cd692caca1bc779e16f9a219a5e10ba04c034ce3482d34d4e90 | R | 131 | 7 | library("drake")
library("dplyr")
library("readr")
library("purrr")
library("tidyverse")
library("MMWRweek")
library("data.table")
|
629a935ea0ae93c5b72335d1be1e524b3698127d2bafcb37336a0048076d9258 | R | 151 | 9 | dot.product = function(x, y) {
x = sqrt(x)
y = sqrt(y)
prod = sum(x * y)
if (prod == 0)
0
else
prod / sqrt(sum(x * x) * sum(y * y))
} |
f31c87f010699a75a5bb9f5a557fbe5fea1d39ba66152ecb7a94530249bf9494 | R | 157 | 5 | # transpose otu_table and then convert it to data.frame
#' @importMethodsFrom phyloseq t
transpose_and_2df <- function(ot) {
t(ot) %>% as.data.frame()
}
|
70cd5ee878fa61f7d82d2b9edab156bfdc22d35ab50f18b29a45430072fbf763 | R | 224 | 8 | imgurl <- "man/figures/microbiome.png"
sticker(
subplot = imgurl,
package="microbiomeMarker",
p_size=14, s_x=1, s_y=0.75 , s_width = 0.6, asp = 0.8,
filename="man/figures/microbiomeMarker.png",
h_color = "grey"
)
|
eb03368ef7face3f088fadf472994410ebcb9b54466036bee08ac9a36595836a | R | 248 | 10 | test_that("result of edger", {
data(pediatric_ibd)
mm_edger <- run_edger(
pediatric_ibd,
"Class",
pvalue_cutoff = 0.1,
p_adjust = "fdr"
)
expect_snapshot(print(marker_table(mm_edger), digits = 5))
})
|
63711d0c5f633a49d28d78ab64533e664b708454d58085988ac001c5e2121064 | R | 250 | 7 | normalize.intensity = function(data, max.intensity = 100) {
normalized.intensity = data[, 2] / max(data[, 2]) * max.intensity
normalized.intensity[normalized.intensity < 0] = 0
new.data = data
new.data[, 2] = normalized.intensity
new.data
} |
addfc919c6b73719a824447f342133c7622b54e8ddc4a25ae077d92e83e58dd0 | R | 251 | 10 | #' Get all forecast files in a directory
#'
#' @return a list of file names
#'
get_forecast_files <- function() {
list.files(path = "data-processed",
pattern = "*.csv",
full.names = TRUE,
recursive = TRUE)
}
|
2a78e7ad046777aa7df6ea84d9187b8e5e40837fe3fb15888d1cedd0c18bd2b6 | R | 257 | 9 |
library(ggsegExtra)
atlas_repo <- ggseg_atlas_repos("ggsegTracula", ignore.case = TRUE)
install_ggseg_atlas(repo = atlas_repo$repo, source = atlas_repo$source)
library(ggseg)
library(ggsegTracula)
ggseg(atlas = tracula,
mapping=aes(fill = region))
|
054064388827960ba64d4f82eb7a8c8a5b784a8786297ee12a92e4dd9f2715f3 | R | 280 | 6 | install.packages('remotes')
remotes::install_github('reichlab/zoltr')
remotes::install_github('epiforecasts/scoringutils')
remotes::install_github('reichlab/covidHubUtils')
remotes::install_github("Chicago/RSocrata")
install.packages(c('tidyverse', 'rvest', 'here', 'covidcast'))
|
51b52abd08a406eacea87c34b8a2a500f16552d2dfd6225dc2867bc78931a240 | R | 298 | 5 | lapply(list.files(pattern = '_charge[0-9]+.+\\.ions\\.json$'), function(file) {
ions = rjson::fromJSON(file = file)
spectra = ions.to.spectra(ions, charge = as.integer(sub('charge', '', stringr::str_extract(file, 'charge[0-9]+'))))
write.msp(spectra, sub('\\.ions\\.json$', '.msp', file))
})
|
70adc2aa2e47a78684954af72c6fef5903a4dca2d7d012250787b437c47b22ea | R | 315 | 11 | # available taxonomic ranks, Summarize represents summarized tax
available_ranks <- c(
"Kingdom", "Phylum", "Class", "Order",
"Family", "Genus", "Species"
)
available_ranks <- factor(
available_ranks,
levels = available_ranks
)
usethis::use_data(available_ranks, internal = TRUE, overwrite = TRUE)
|
77c5df5846cd28326d9db1583cc6047c85c75438484af40b6eccadb2f4aa7f22 | R | 333 | 12 | test_that("extract methods", {
marker <- marker_table(
data.frame(
feature = paste0("sp", 1:5),
enrich_group = c("cr", "er", "cr", "cr", "er"),
stringsAsFactors = FALSE
)
)
expect_s4_class(marker[1], "marker_table")
expect_s4_class(marker[1, ], "marke... |
9e19744e74328248d29edb7bd997d55416f07603c3ad08d073b483c7c8ab7974 | R | 342 | 9 | get_all_forecast_dates = function (forecast_files){
dataframes =list()
for (file in forecast_files){
items = unlist(str_split(file, pattern = "/|-|\\."))
dataframes[[file]] = data.frame(team = items[3], model = items[4], forecast_date = as.Date(paste(items[5],items[6],items[7], sep='-')))
}
dplyr::bi... |
3c63f57641993d42560a95e4ee704fc0bceaa9d5b8aafa14aa40728b81afff02 | R | 373 | 8 | test_that("whether the row.names of feature table is dna sequence or not", {
expect_false(is_dna_seq("3597a2689efaf5525ce460494a8ac383"))
expect_true(is_dna_seq(paste0(
"TACGGAGGATGCGAGCGTTATCCGGATTTATTGGGTTTAAAGGGTGCGTAGGTG",
"GTGATTTAAGTCAGCGGTGAAAGTTTGTGGCTCAACCATAAAATTGCCGTTGAA",
"AC... |
40ea51515c8bdeedd73c47e71d30defa4644512f2a0eaa469ff407db277effc3 | R | 375 | 9 | #!/usr/bin/env Rscript
args <- commandArgs(trailingOnly = T)
dat=read.table(args[1], stringsAsFactors = F, header = T)
cols=colnames(dat)
for (cn in cols[grepl(pattern ="p.val", x = cols)] ){
dat[,paste0(cn,"_BH_adjusted")]=p.adjust(dat[,cn], method = "BH")
}
write.table(x=dat, file = paste0(args[1], "_adjusted.tsv"... |
d8b2f7b9b8dd5cbe3d14431ad4ae6ca9702161b90e57624d10829c1fbbc3b401 | R | 388 | 4 | groot=readRDS('/sdata/images/projects/UKBIOBANK/ABCD/release2.0/iii.data/ABCDgenomic/genomics_sample03.rds')
pheno=data.frame(groot$subjectkey,round(runif(nrow(groot),min = 0,max = 1),digits = 0))
write.table(pheno,file = '/sdata/images/projects/UKBIOBANK/users/Shen/iv.ABCD/release2.0/FamilialRisk_PGRS_MDD/data/pheno.f... |
e5078caa932d92c7053ca71c1d24bf2d7b103fd81657ec9a2f7ebb8e6d4a24fa | R | 421 | 14 | #' Calculate the date of the next Saturday
#'
#' @param date date for calculation
#'
#' @return a date of the subsequent Saturday. if date is a Saturday, it will return this day itself.
get_next_saturday <- function(date) {
require(lubridate)
date <- as.Date(date)
## calculate days until saturday (day 7)
... |
944d7553a6d77fb3b95f6b57dda98d4f66d646906b271acef7293cc384d01bf8 | R | 427 | 11 | test_that("import_picrust2 works", {
sam_tab <- system.file(
"extdata", "picrust2_metadata.tsv",
package = "microbiomeMarker")
feature_tab <- system.file(
"extdata", "path_abun_unstrat_descrip.tsv.gz",
package = "microbiomeMarker")
ps <- import_picrust2(feature_tab, sam_tab, ... |
ea92813e30cd1060f9dada0d28c8f27e0e9fba33a354a64bf8ef8d12ac98af99 | R | 439 | 24 | #library(igraph)
suppressMessages(library(igraph))
args <- commandArgs(trailingOnly = TRUE)
fi <- args[1]
minn <- args[2]
maxn <- args[3]
fo <- args[4]
df <- read.table(fi, header = FALSE)
g <- graph.data.frame(df, directed = FALSE)
cl <- vector()
for (i in minn:maxn) {
x <- cliques(g, min = i, max = i)
cl <- c(... |
335206fa51ac84551bfbbeadf0dde8d520e312bd5039111f5ffca2031c954065 | R | 443 | 24 | #library(igraph)
suppressMessages(library(igraph))
args <- commandArgs(trailingOnly = TRUE)
fi <- args[1]
minn <- args[2]
maxn <- args[3]
fo <- args[4]
df <- read.table(fi, header = FALSE)
g <- graph.data.frame(df, directed = FALSE)
cl <- vector()
for (i in minn:maxn) {
x <- max_cliques(g, min = i, max = i)
cl <... |
15274a0265c4dcabbd9e74b2c19509bdf571422c555af8fa57cb6f174229e124 | R | 465 | 16 | test_that("limma voom", {
data(enterotypes_arumugam)
enterotype <- phyloseq::subset_samples(
enterotypes_arumugam,
Enterotype %in% c("Enterotype 1", "Enterotype 2", "Enterotype 3")
)
mm_lv <- run_limma_voom(
enterotype,
"Enterotype",
contrast = c("Enterotype 3", "... |
e86c471b8c48f77108d9c0f67db56d9923a144e848937d00f5c19386ed4f6603 | R | 476 | 13 | #' Get forecast target
#'
#' @param d a forecast data.frame
#' @return a data.frame with a count for the number of forecasts for each target
#'
get_forecast_targets <- function(d) {
d %>%
# add location
dplyr::group_by(model_abbr, forecast_date, type, unit, ahead, inc_cum, death_cases) %>%
dplyr::summar... |
fe72275bcf7f3c408464ec98310ed0d5da3d73d44c88be3b34ce7f3aff484efb | R | 477 | 7 | library(covidData)
library(covidHubUtils)
# covidHubUtils::preprocess_nytimes("./covid19-forecast-hub/data-truth/nytimes/")
# covidHubUtils::preprocess_jhu("./covid19-forecast-hub/data-truth/")
# covidHubUtils::preprocess_visualization_truth("./covid19-forecast-hub/visualization/vis-master/covid-csv-tools/dist/truth")
... |
dafdb1d6a0a07b911f4d39faf71a7c1b6b3da2b4712c0e6666722ed92bf08fe2 | R | 478 | 15 | FROM rpy2/base-ubuntu:latest
# Change the tag in the image_name:tag above to a different version, if required.
# Available tags: https://hub.docker.com/r/rpy2/base-ubuntu/tags
ADD . /gluonts
RUN pip install "/gluonts[shell,R]"
RUN R -e 'install.packages(c("forecast", "hts"), repos="https://cloud.r-project.org")'
RUN... |
8f3f5d4db5a930d0c0d906e303ffe498de3128de9ce72a11aae43ac3b8a0f34f | R | 485 | 15 | #' Summarize prediction quantiles for a model
#'
#' @param d a forecast data.frame
#' @return a data.frame with quantiles summaries
get_forecast_quantiles_summary <- function(d){
d %>%
dplyr::group_by(model_abbr, forecast_date) %>%
dplyr::summarize(
all_full = ifelse(all(full), "Yes", "-"),
any_f... |
9523a63d119c27e403d47f5e913670d26336dfbdaa62cc5d48706edc939e3eb6 | R | 485 | 15 | source("code/validation/R-scripts/functions_plausibility.R")
### THESE CODES ARE NO LONGER MAINTAINED OR KEPT IN SYNC WITH THE AUTORITATIVE PYTHON CHECKS
### THEY ARE KEPT HERE MERELY AS A RESSOURCE FOR TEAMS SPECIALIZING IN R.
# make sure locale is English US
Sys.setlocale(category = "LC_TIME", locale = "en_US.UTF8"... |
bdc53a777be1f59e0368cc9b998abadeb59cf86ab81e5547a1e833fe89baa013 | R | 493 | 12 | library(brms)
library(emmeans)
library(bayestestR)
dat<-read.csv("../data/school_area_pearson.csv")
dat$n_schools<-factor(dat$n_schools)
dat$area<-ordered(dat$area)
mod.orig<-brm(pearsonr~n_schools*mo(area),data=dat,cores=4,seed=42)
mod.mat<-as.data.frame(mod.orig)
describe_posterior(data.frame(s1=mod.mat$bsp_moarea,
s... |
2942cc87a01de7ce1e34594818bed2b253092b0ed8b25235904bf99782f9c9a1 | R | 504 | 15 | library(data.table)
setwd("~/work/ibs")
replication_dir = "clump/replication"
files = list.files(replication_dir,pattern="^(replication_)")
exclude = grepl("(^replication_for)|(^replication_counts)",files)
files = files[!exclude]
print(files)
paths = paste0(replication_dir,"/",files)
all = rbindlist(lapply(paths,fread)... |
f29bed61b32599ca106801b40f842d785f857a5a5bcf413cbd36006f2e2dc0c7 | R | 527 | 18 | #' Extract `marker_table` object
#'
#' Operators acting on `marker_table` to extract parts.
#'
#' @name [
#' @aliases [,marker_table,ANY,ANY,ANY-method
#' @param x a [`marker_table`] object.
#' @param i,j elements to extract.
#' @param ... see [`base::Extract()`].
#' @param drop ignored now.
#' @return a `marker_table`... |
7714f86751dfa7e107e43c746c54595625651c11faa1fdbae96813502aa373c8 | R | 539 | 20 | wholeB_correction<-function(TargetResult,ls.factor,ls.dep){
for (f in ls.factor){
chunk.f=TargetResult[TargetResult$factor==f,]
for (d in ls.dep){
chunk.d=chunk.f[grep(d,chunk.f$dependent),]
chunk.d$p.corrected=p.adjust(chunk.d$p.value,method='fdr')
if (d==ls.dep[1]){
tmp.collate=chu... |
4441245796cc64b2b70ec2912d1635e50fe9e4dd913452e8872ede65e4e7cb3d | R | 540 | 17 | #' Get forecast data.frame to plot
#'
#' @param d a data.frame with the latest forecast from each model
#' @return a data.frame with forecast, quantiles and targets
#'
get_latest_plot_data <- function(d){
d %>%
filter(quantile %in% c(.025,.25,.5,.75,.975) | type == "point") %>%
mutate(quantile = ifelse... |
baab7ccd90e3608f617f932cf159efd685bc8b065353be46167516e548bdb6df | R | 565 | 17 | ## make template
library(tidyverse)
## shared parameters/data across state/national templates
death_targets <- c("1 day ahead inc death", "2 wk ahead cum death")
qntls <- c(0.01, 0.025, seq(0.05, 0.95, by = 0.05), 0.975, 0.99)
template <- tibble(
target = rep(death_targets, each=length(qntls)+1),
location = ... |
cf1764f23f467163d4a3149cdddab354f69695494bdd2fc9e485554e692d467d | R | 588 | 19 | lossRatio = 50
budding = 100
lapply(list.files(pattern = '_charge[0-9]+.+\\.ions\\.json$'), function(file) {
ions = rjson::fromJSON(file = file)
spectra = ions.to.spectra.loss.budding.1(
ions,
charge = as.integer(sub('charge', '', stringr::str_extract(file, 'charge[0-9]+'))),
loss.ratio = lossRati... |
542d6ba39d4be67f44b92485eab081367ff4a43058e7d664d25442301b28c372 | R | 604 | 19 | ## table with important dates
## due dates: Mondays
forecasts_collected <- seq(as.Date("2020-03-16"), as.Date("2020-10-30"), by="1 week")
forecasts_collected_ew <- paste0(
MMWRweek(forecasts_collected)$MMWRyear,
"-ew",
MMWRweek(forecasts_collected)$MMWRweek
)
## 1-week ahead
forecast_1_wk_ahead_start <- ... |
5e7aab1cd574d3e46bd60d66e930db71ecbc8423733c5456d74605da4454f249 | R | 606 | 21 | test_that("supervised machine learning method workds properly", {
data(enterotypes_arumugam)
ps_small <- phyloseq::subset_taxa(
enterotypes_arumugam,
Phylum %in% c("Firmicutes", "Bacteroidetes")
)
set.seed(2021)
mm_lr <- run_sl(
ps_small,
group = "Gender",
tax... |
a1688d3e5977ad88d4a822ddd3776b79bf0ee16506a367e3df722825142ef311 | R | 614 | 18 | #' Get truth file
#'
#' @param file file path
#' @param inc_cum "inc" or "cum"
#' @param source "JHU-CSSE" or "USAFacts" or "NYTimes"
#' @return a data.frame of truth data
#'
get_truth <- function(file, inc_cum, source) {
data.table::fread(file,
colClasses = c(
"date" ... |
010d98da728115b6a90a7f7499b003f22af719abd78c1a76bc4c34283c8f9603 | R | 635 | 18 | get.candidate.sites = function(sequence, mod.name = 'Oxidation', aa = 'M', max.count = 3) {
positions = stringr::str_locate_all(sequence, paste0('[', paste0(aa, collapse = ''), ']'))[[1]]
if (nrow(positions) == 0) {
return(NULL)
}
lapply(1:max.count, function(modCount) {
if (nrow(positions) < modCoun... |
ab0363deb6eb7cf92e13b33844f6042d85a0ea975cf7475ccbadf76e0de641e3 | R | 661 | 20 | lossRatio = 50
lapply(list.files(pattern = '_charge[0-9]+.+\\.ions\\.json$'), function(file) {
ions = rjson::fromJSON(file = file)
if (grepl('[ST]phospho1', file)) {
spectra = ions.to.spectra.loss(
ions,
charge = as.integer(sub('charge', '', stringr::str_extract(file, 'charge[0-9]+'))),
los... |
b72359736b5e5a510bc0231e0e67f8b091dbb5a040f0fdfde9a4dd65fe8c086a | R | 665 | 25 | test_that("ration", {
abd1 <- rep(0, 6)
abd2 <- rep(0, 6)
expect_equal(calc_ratio(abd1, abd2), 0)
abd1 <- c(0.00014940, 0.05774625, 0.05419578, 0.05414964, 0.02028051)
abd2 <- rep(0, 5)
expect_equal(round(calc_ratio(abd1, abd2), 5), 1.00278)
abd2 <- rev(abd1)
expect_equal(round(calc_ra... |
c2b7eca8f2d82363d6159bf0e0ca0698a93460c9d66c1a2d8224fa6ab2fc3468 | R | 717 | 18 | #' microbiomeMarker: A package for microbiome biomarker discovery
#'
#' The microboimeMarker package provides several methods to identify micribome
#' biomarker, such as lefse, deseq2.
#'
#' @docType package
#' @name microbiomeMarker-package
#' @aliases microbiomeMarker-package
#' @importFrom dplyr %>% group_by summari... |
9d95bc3b36bf03caf7ba93b9471e7624ff58a816f2478e73f95591ed2a2394f0 | R | 719 | 21 | test_that("fix duplicate tax", {
ps <- readRDS("data/data_tax_duplicate.rds")
ps_fixed <- fix_duplicate_tax(ps)
expect_fixed_length_qual <- function(ps, ps_fixed, level) {
tax <- tax_table(ps)@.Data
l <- length(unique(apply(tax[, 1:level], 1, paste, collapse = "_")))
tax_fixed <- t... |
fba591d488920e9b15de24420a9c0162b3c03a3a52c5bc15d57069f79a49295b | R | 720 | 31 | read.tcsv = function(file, header=TRUE, sep=",", ...) {
n = max(count.fields(file, sep=sep), na.rm=TRUE)
n2=max(count.fields(file, sep=';'), na.rm=TRUE)
if(n2>n) {
n=n2
}
lines = readLines(file)
for(i in 1:length(lines)) {
lines[i]<-gsub(';',',',lines[i])
}
.splitva... |
9b2981b158ddb838b7fc9f8a2fc2eedb6b6b1d2110fb12c6e51d7d0fb2e839b9 | R | 744 | 20 | apply_constraints = function(subj_df) {
# Locomotion mutually exclusive from everything but 'Lip.smack', 'Fear.grimace', 'Threat.face', 'Coo', 'Grunt, 'Bark', 'Approach', 'Displacement', 'Flee', 'Withdraw'
locomotion_state<-subj_df$Locomotion>=1
col_names<-colnames(subj_df)
for(i in 1:length(col_names)) {
... |
f75474712ac99a64d22e513b9a4fb2bd359079fd0b5669ad507a6993368b8826 | R | 759 | 29 | # lefse - lda
data(kostic_crc)
kostic_crc_small <- phyloseq::subset_taxa(
kostic_crc,
Phylum == "Firmicutes"
)
mm_lefse <- withr::with_seed(
2020,
run_lefse(kostic_crc_small,
wilcoxon_cutoff = 0.01,
group = "DIAGNOSIS",
kw_cutoff = 0.01,
multigrp_strat = TRUE,
lda... |
a26f2572dfc00c02a11e4ce8ce417d658ca721775c05287bc9fd520a0e73981d | R | 774 | 19 | library("drake")
R.utils::sourceDirectory("code/shiny/R",modifiedOnly=FALSE)
forecast_files = get_forecast_files()
latest_forecast_files = get_latest_forecast_files(forecast_files)
latest_ids = rlang::syms(lapply(latest_forecast_files,
function(f) unlist(strsplit(as.character(f), "/"... |
1c5435776a133b1bf9758d8c81c0ff6ee856c274eca9aebc45164ee653e7cffe | R | 776 | 21 | #' Summarize prediction quantiles for a forecast
#'
#' @param d a forecast data.frame
#' @return a data.frame with quantiles summaries
get_forecast_quantiles <- function(d){
quantiles = list(
full = sprintf("%.3f", c(0.01, 0.025, seq(0.05, 0.95, by = 0.05), 0.975, 0.99)),
min = sprintf("%.3f", c(0.01, 0.05,... |
379e852195d28a54b1db21c4c950b1d9b4c842b9b334ab70885a531081f7386f | R | 791 | 21 | #' Get latest forecast files for each model
#'
#' @param files a list of all forecast file names
#' @return a list of latest forecast file names
#'
get_latest_forecast_files <- function(files) {
data.frame(file = files) %>%
tidyr::separate(file,
into = c("data","processed","team_abbr","mode... |
8dc05638c29fde9aae230763863d7bd8bb1c90f4281d31e3e6544bdb4a0ba106 | R | 828 | 26 | test_that("Generate unique id for short annotation label", {
uid <- get_unique_id(500)
expect_equal(uid[26], "z")
expect_equal(uid[30], "ad")
expect_equal(uid[260], "iz")
expect_equal(uid[500], "sf")
})
test_that("drop the levels (no marker) if the enrich_group is a factor", {
marker <- readRDS... |
0899b686768369552cbca13447e869d40289606a65960aa98066e97a1775a336 | R | 865 | 33 | marker <- marker_table(
data.frame(
feature = paste0("sp", 1:5),
enrich_group = c("cr", "er", "cr", "cr", "er"),
stringsAsFactors = FALSE
)
)
otu <- otu_table(
data.frame(
s1 = runif(10),
s2 = runif(10)
),
taxa_are_rows = TRUE
)
tax <- tax_table(data.frame(fea... |
51768be145cbff8f0b464e73edf39d2f8252e2e2e0ffc4c714d1c25e7784716c | R | 871 | 52 | ---
title: "Adolescent MDD & Brain: Main Results"
author: "X Shen"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
html_document:
toc: true
toc_depth: 4
code_folding: hide
---
* * *
## Contact
X Shen (xueyi.shen@ed.ac.uk)
* * *
## R settings
Required packages:
- dplyr
- readr
- ggplot2
Ex... |
81896e36de060868acab8ee048b005fe1ec561522f21fb052f2da824106b8ad3 | R | 873 | 22 | #' Summarize locations for forecasts
#'
#' @param d a forecast data.frame
#' @return a data.frame with location summaries
get_forecast_locations <- function(d) {
d %>%
dplyr::group_by(model_abbr, forecast_date) %>%
dplyr::summarize(
US = ifelse(any(abbreviation == "US"), "Yes", "-"),
n_states = ... |
914a160bb2352e17814eb6a90f75dd4962c88ae3bb49eb1b70a66ca0b106a778 | R | 880 | 25 | fill_gaps<-function(state, thresh) {
state_bin<-state>=1
state_diff<-state[2:length(state)]-state[1:length(state)-1]
state_diff_bin<-state_bin[2:length(state)]-state_bin[1:length(state)-1]
start_times<-which(state_diff==1)
end_times<-which(state_diff==-1)
if (length(end_times)<length(start_times)) {
... |
55ad3878e0dd06d0df06b029701c5636c16bb5f7b150c7b9ec5c2f56b0f492ed | R | 889 | 25 | library(readr)
lapply(list.files(pattern = '\\.peptide\\.csv$'), function(f) {
peptides = read_csv(f)
lapply(2:3, function(charge) {
peptidetxt = data.frame(
peptide = peptides$sequence,
modification = paste(
sapply(strsplit(peptides$modification, ';'), function(s) {
paste(sapp... |
6e46b13486f3d47f8c1d32b9e6fa30e1611a68cc9842ff39636eda091523659f | R | 901 | 29 | budding = 100
lapply(list.files(pattern = '_charge[0-9]+.+\\.ions\\.json$'), function(file) {
ions = rjson::fromJSON(file = file)
if (grepl('[ST]phospho1', file)) {
spectra = ions.to.spectra.budding(
ions,
charge = as.integer(sub('charge', '', stringr::str_extract(file, 'charge[0-9]+'))),
b... |
d4bcb646761d82a3de624ba3e722f80b83b35771df48e870dcc25a4cda24e675 | R | 937 | 26 | #Insert path name to bottleneck for best run according to log-rank p-value
bottleneck <- read.csv("")
#Insert path name to clinical file
clinical <-read.csv("")
#Select time and event columns from clinical file
clinical <- clinical[c(2,3)]
newdf <- c()
for (i in 2:101){
combo <- cbind(clinical, bottleneck[i])
colna... |
ffb19c4efac2cd580c8d7b3d58d2bbb3cdc55ebfae50033ed6d52d89d285d8bc | R | 983 | 31 | lossRatio = 50
budding = 100
lapply(list.files(pattern = '_charge[0-9]+.+\\.ions\\.json$'), function(file) {
ions = rjson::fromJSON(file = file)
if (grepl('[ST]phospho1', file)) {
spectra = ions.to.spectra.loss.budding(
ions,
charge = as.integer(sub('charge', '', stringr::str_extract(file, 'charge... |
7e3727ce85b594348feb71317e306adde79669a8980baa8600105122ee66f295 | R | 1,018 | 35 | #' Subset microbiome markers
#'
#' Subset markers based on an expression related to the columns and values
#' within the `marker_table` slot of `mm`.
#'
#' @param mm a [`microbiomeMarker-class`] or [`marker_table-class`] object.
#' @param ... the subsetting expression passed to [`base::subset()`].
#' @return a subset o... |
bb83f8883024f006e6e664fa30f2a6169b676fb867b269be8f1654888f9baadb | R | 1,043 | 23 | #' Process location file so that each county has a corresponding state
#' it belongs to
#'
#' @param file location.csv
#' @return a data.frame with state, county and fips code
#'
get_locations = function(file) {
data.table::fread(file,
colClasses=c(
"abbreviation" = "c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.