sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
f9cdb5335d630d8a8ef6015bee330ccf5e90014bfa9f9341cada67095ce8c10f
Python
8,432
210
import pandas as pd from pgmpy.base import DAG from pgmpy.estimators import ParameterEstimator from pgmpy.factors.discrete import TabularCPD from pgmpy.models import DiscreteBayesianNetwork from pgmpy.parameter_estimator import DiscreteBayesianEstimator, DiscreteEM from pgmpy.utils._warnings import _warn_external cl...
bee8110d1510137578d0da9a856eb5aff174c165daadafba11472e9e94dfa643
Python
8,433
232
# /usr/bin/env python ''' Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md ''' import os import numpy as np import time import torch import CBIG_pMFM_basic_functions as fc import warnings def get_init(myelin_data, gradient_data, highest_order, init_para):...
8966b2febd0f1b52f4a39cca976b759331ec2c459ce60ef4ed2f6d71f94ae888
Python
8,437
236
# encoding: utf-8 """ @author: Jiayang Chen @contact: yjcmydkzgj@gmail.com The required parameters include model_path, data_path, save_path, save_type Given the input sequences, output and save specific predictions """ import argparse import os import sys from os import mkdir import torch from torch.backends impor...
96302fe74db1b671f7942e550310feefd725c7b7a91088bbefe39f480801e349
Python
8,439
242
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging from pathlib import Path from typing import Dict, List, Optional from dataclasses import dataclass import torch from fairseq.d...
e8649fe21de30fd8e5c3cd930c9ed191da49748a6f188abaa07b41e47041780a
Python
8,440
240
"""Configuration for Garfield""" import os import seaborn as sns import matplotlib as mpl class GarfieldConfig: """configuration class for Garfield""" def __init__(self, workdir="./result_Garfield", n_jobs=1): self.workdir = workdir self.n_jobs = n_jobs self.set_gf_params(...
878f6aa1ac89d8793c53525bbaeaf14b92817306f06b453d44221dc6cec88cf2
Python
8,445
242
## functions for mTE analysis # # written by S-C. Baek # update: 16.12.2024 # """ Collection of functions to run multivariate transfer entropy (mTE) analysis. The code here were mainly created by tranlating the original MATLAB code in the following Github repository: https://github.com/ide2704/Kernel_Renyi_Transfer_Ent...
268ff79eff50f00db34baeca65e23bac1ba7baf3599709be9d6baf66c70a6c9a
Python
8,448
252
# extract_timeseries_c3.py # Extract timeseries for cluster C3 (ds003721) from *preprocessed* SPM outputs, # using Cambridge/BASC multiscale atlas at a fixed scale (e.g., scale064). import os, glob, json import numpy as np try: from nilearn.maskers import NiftiLabelsMasker except Exception: from nil...
c830f176e267c351116bde85b03ddf5d793e397a57bde70c3cf5ff733e086cd8
Python
8,449
233
from collections.abc import Iterable as IterableClass import pandas as pd from rich import print from scvi import REGISTRY_KEYS from scvi.external.scviva import SCVIVA_REGISTRY_KEYS from scvi.model.base._de_core import _fdr_de_prediction, _prepare_obs from scvi.model.base._differential import DifferentialComputation ...
de01a5ac521e27d3758f207240dda98eb7fbd9023508c3cb7e2392ac97eee59a
Python
8,450
241
import os import pandas as pd import gzip import GEOparse import numpy as np import mygene dest_dir = "__MS_GEO_ROOT__/Expression_Data" def get_ensg_to_symbol_mapping(ensg_list): mg = mygene.MyGeneInfo() print("Querying mygene for symbols...") results = mg.querymany(ensg_list, scopes='ensembl.gene', field...
03447cd78cf43bb969fd847a950d22ef8f2c5b50e5b62161cb59e6db33c85bf1
Python
8,451
224
# /usr/bin/env python ''' Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md ''' import os import numpy as np import time import torch import CBIG_pMFM_basic_functions as fc def get_init(myelin_data, highest_order, init_para): ''' This function is i...
67b55171e39334f7f4f8670ec4b6009e45c55879022aafb08f19721eae06e1a6
Python
8,455
222
#!/usr/bin/env python3 """Select regions from a bed file to match the GC distribution of a reference bed. For training bias models, the ChromBPNet method requires that the bias regions match the peaks regions in GC content. This little script arranges for that. You feed it two bed files. One represents your training ...
568f23c1890d96e63f4a559876de81683cf2efd7ab9f4f541469e9162052ac3f
Python
8,460
225
# -*- coding: utf-8 -*- """ Created on Mon Jul 15 11:52:25 2019 @author: 俊男 """ # In[] Import Area import numpy as np import matplotlib.pyplot as plt from matplotlib.colors import ListedColormap import pandas as pd # In[] sample_model(): Draw the model as line, and sample data as scatter # USAGE: model_drawer.sample...
b14835e8e973d41bd23b45ec8a3e7365683a8e6c320ba3e279669ec9c41d8ff5
Python
8,463
270
from lifelines import CoxPHFitter import pandas as pd import numpy as np from sklearn.model_selection import StratifiedKFold from sklearn.preprocessing import StandardScaler import warnings basedir = "..\\Data\\" outbasedir = "..\\Out\\" alg = 'COXPH' ctype = 'BLCA' dataseed = 100 algnpseed = 13333300 survindex =...
f9bab035f5b5c4f5536ef892b3d6732ae5ce1216b23131590636be91fc34e8b5
Python
8,463
175
import os import pandas as pd import torch import numpy as np from torch.utils.data import Dataset, DataLoader, TensorDataset from transformers import BertTokenizerFast, PreTrainedTokenizerFast, AutoTokenizer,BertTokenizer, DistilBertTokenizer, BertForMaskedLM, RobertaTokenizer, XLNetTokenizer, AlbertTokenizer, Electra...
07f3e756296dbd92f0b6a59c1c32b0c3e32509423d09a786b8bab6f6bc5f9978
Python
8,471
270
import copy import glob import os import random import numpy as np import pandas as pd import torch import torch.nn as nn import torch.nn.functional as F from scipy.stats import binned_statistic from torch.utils.data import Dataset from torchvision import transforms from tqdm.auto import tqdm class AddGaussianNoise:...
2ca1fb5c629f08b6afd3e2a68d5eb50259e5bfa3f625d524b3d9d263c0804922
Python
8,473
186
import numpy as np from phantoms.phantom import phantom import func.geometry_func as gf import func.BphP_func as bf import logging #logging.basicConfig(level=logging.DEBUG) class BphP_cylindrical_phantom(phantom): def gen_regions(self, cfg : dict, rng : np.random._generator.Generator, ...
fdf5e6a6a71965c0427cf54c871bde4fe8bcf61b997bff50579913f4cc91dda4
Python
8,474
212
"""Phase 17 — drive DFT/AIREBO ratio spread below 1% via more realizations. Variance decomposition (phase 12+15+16) showed σ_within = 0.0716 dominates σ_between = 0.0313; the 2.4% cross-lattice spread is statistically consistent with a single common ratio. Need n=30 per lattice → ratio SEM ~1%. Adds 24 more clusters...
4a5e9f092e7f08daadd12b8bc954f0d6a6fb8fbf3ab16f9b86e24d1cdd964696
Python
8,478
211
import numpy import pandas import logging from .JointAnalysis import Context, ContextMixin from .. import MatrixManager from .. import Exceptions from .. import PredictionModel from ..misc import GWASAndModels from ..misc import DataFrameStreamer from ..misc import KeyedDataSource from ..genotype import GeneExpression...
a5d8643acf14499158abce570fe933e21ac43e8ff7ba14b738e526210a22a443
Python
8,479
245
""" Acr sampling pipeline using Evo. Usage: python pipelines/acr_sample.py --config <config_file_path> """ import argparse import sys from dataclasses import dataclass, field from pathlib import Path from typing import Any, Dict PACKAGE_ROOT = Path(__file__).resolve().parents[1] if str(PACKAGE_ROOT) not in sys.path:...
03327199697929c71462f3d503cc238ca67117bc191d4c21c8ccbe95279195cb
Python
8,480
189
import tqdm import multiprocessing import pandas as pd import numpy as np import scipy.stats from sklearn import linear_model from sklearn.model_selection import KFold from sklearn.metrics import mean_squared_error,mean_absolute_error from sklearn.ensemble import RandomForestRegressor from sklearn.preprocessing import...
0296ad1a87cc9d4fa4f49df16cf79f3f88a84351e43d1cb906d00f4536125684
Python
8,487
218
import pyBigWig from Bio import SeqIO import polars as pl from src.utils import gtf_to_SJ, read_gtf, read_SJ import os import numpy as np import polars.selectors as cs from pathlib import Path bw = "data/hg38.phyloP100way.bw" pbw = pyBigWig.open(bw) genome = list(SeqIO.parse(os.getenv("GENOMIC_DATA_DIR") + "/GENCODE/...
7b1180faea1750033fd2256e6897a42b26a89ee6a43fc649dcda5c86870c710a
Python
8,488
203
## # Doxygen filter for Google Protocol Buffers .proto files. # This script converts .proto files into C++ style ones # and prints the output to standard output. # # version 0.6-beta # # How to enable this filter in Doxygen: # 1. Generate Doxygen configuration file with command 'doxygen -g <filename>' # ...
337f9dd75edb897e6e456f5b03dd58164f7b60f149df053075b662b311bd7060
Python
8,489
243
from pathlib import Path import mne import mne_bids import numpy as np import pytest from scipy import signal import pylossless as ll def test_empty_repr(tmp_path): """Test the __repr__ method for a pipeline that hasn't run.""" config = ll.config.Config() config.load_default() fpath = tmp_path / "tes...
6b8cc77d78fba382ae4e770a4e14db28d2b5bfc85ffbf4adbfbe53ae93665aab
Python
8,494
230
# /usr/bin/env python ''' Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md ''' import os import numpy as np import time import torch import CBIG_pMFM_basic_functions as fc import warnings def get_init(gradient_data, highest_order, init_para): ''' ...
ca77f8272b23532d229af9aaefdaf681ec56915286f2bafaf4bd049271605595
Python
8,494
344
import os import torch import numpy as np from torch_geometric.loader import DataLoader from sklearn.model_selection import KFold from scipy.stats import pearsonr from tqdm import tqdm from model import GeometryAwareGNN from model_ablation import GNN_NoRBF, GNN_WithBN ABLATION_MODES = [ "NoRBF", "WithBN", ...
07e0dab3615decab1a33b02c52fec67e274048da84c94320606f05eeab24e9c1
Python
8,497
217
import numpy as np import numpy.matlib as matlib import numpy.linalg as linalg import sys # to implement args later import copy import warnings def LyE_W(x, Fs, tau, dim, evolve): """ inputs - x, time series - Fs, sampling frequency - tau, time lag - dim, embedding dimension ...
02a06b44fcd2b4821264bd9a59fa10a8ebb371d783119bf25dd89839aceb573f
Python
8,499
224
import os import glob from typing import List, Tuple import numpy as np import matplotlib.pyplot as plt try: import pydicom except ImportError as e: raise SystemExit("The 'pydicom' package is required. Install with: pip install pydicom") from e def _find_dicom_files(folder_path: str) -> List[str]: """Re...
c9fd9f7b20beb3aef911576885978400bdcf460ed110f76e6dc23167c64ce340
Python
8,499
220
""" Split a sub-dataset from the training/test set into high-expression and low-expression subsets based on the expression level of a specified gene or protein. Examples of usage: # 1. Median Gating: python scripts/split_by_expression.py \ --input path/to/data/MERFISH_mouse_cortex_test.csv \ --config configs/e...
0e47800acc7cec9bce88aab587d66b6743cf76135c06816728a844ceda3f8add
Python
8,504
210
""" This module runs rna rna interaction prediction. Author: wangning(wangning.roci@gmail.com) Date : 2022/12/7 7:41 PM """ import os.path as osp import argparse from functools import partial import paddle from paddlenlp.utils.log import logger from paddlenlp.transformers import ErnieModel from paddlenlp.datasets i...
84bbd141de74e8be2ce84180efe7e7f92d1ddc111d3977101b712e4b4fd564e6
Python
8,505
320
#!/usr/bin/env python3 """ Human fetal anatomical segmentation pipeline Adapted in Nipype from an original pipeline of Alexandre Pron by David Meunier. parser, params are derived from macapype pipeline Description -------------- Base pipeline for running the dhcp pipeline (segmentation and surface extraction) from a...
c56e9e34c1af8b81a85c1ee82c999868197cca8a05c9a8ea0733b0e1e502d9a9
Python
8,507
238
""" Shared Utility Functions for Medical Image Processing This module provides helper functions for medical image preprocessing including: - Format-specific loading (NIfTI, DICOM) - Anatomical reorientation - Physical spacing computation - Standardized preprocessing pipeline These utilities support the main image loa...
41bd77278c8bb62764d0a7a913be9706910b775dd112dcb090afdb91d0ca23b4
Python
8,514
238
import torch from torch import nn, Tensor, FloatTensor import torch.nn.functional as F from typing import Dict, Iterable, Callable from PIL import Image import numpy as np from math import exp from scipy import optimize from lucent.optvis import param, transform from lucent.optvis.objectives import wrap_objective d...
c6cf6111c6d42509a9756148c127790a817dd400bb55dd601899d5c0311ff881
Python
8,514
170
#!/usr/bin/env python3 # MIT License # # Copyright 2024 Broad Institute # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to u...
321f866345f2cbc12d83c63389ba53ca6072993ed3f93a14f7cd386d75b55676
Python
8,515
215
#!/usr/bin/env python3 """Minimal HIPPIE-WF+3DACG trainer for the CVAE-only experiment harness. Trains HippieWF3DACGCVAE on one or more C4 H5 files and saves a checkpoint for the G1–G7 experiments. Multi-dataset training is required for source/ super_region/technology embeddings to be informative — single-dataset = co...
302c4571da7afc4935b604b90be81c06e418bb06fd35f27a4f77585e0a759d38
Python
8,519
182
# coding=utf-8 import os import sys sys.path.append("..") sys.path.append("../utils") import numpy as np import cv2 import random import torch from torch.utils.data import Dataset import config.cfg_lodet as cfg import dataload.augmentations as DataAug import utils.utils_basic as tools class Construct_Dataset(Datase...
1a9691eb28b082e57a4c35d42accf428709e68b0e4c056505326df658950a1f9
Python
8,520
225
# /usr/bin/env python ''' Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md ''' import os import numpy as np import time import torch import CBIG_pMFM_basic_functions as fc def get_init(gradient_data, highest_order, init_para): ''' This function is...
2ed79555cec01e5cbd542db828761b7ebf34c0ab2be712b802c5387966b2a1b9
Python
8,523
202
"""This module contains some routines for sorting volumes and lists voxel-wise. For example, in some applications it can be desired to sort volume fractions voxel-wise over an entire volume. This module contains functions for creating sort index matrices (determining the sort order), sorting volumes and lists and anti...
2b1433abe19a4821346f4715271dacfbea1435e95c6f2e335812e5af41087180
Python
8,527
239
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn as nn class RowSelfAttention(nn.Module): """Compute self-attention over rows of a 2D input.""" ...
e9050bcbe794084857e0abcdc925b78d6f321b2bc47e54edd46852fb963fa8af
Python
8,537
200
import os import polars as pl import sys import glob pl.enable_string_cache() def read_gtf(file, attributes=["transcript_id"], keep_attributes=True): if keep_attributes: return pl.read_csv(file, separator="\t", comment_prefix="#", schema_overrides = {"seqname": pl.String}, has_header = False, new_columns=...
2e7d5d95a206248063aac0477c035eb06cc6d381bcf6f7326b4b979ef1b59009
Python
8,539
244
# Copyright 2021 RangiLyu. # # 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 or agreed to in wri...
767baa13735e02dec9f8eb290718ddba91e154c04fcd35897ef6aa0905c385c1
Python
8,540
264
"""Tests for RAG-GNN model.""" import numpy as np import pytest from rag_gnn import RAGGNN, GNNEncoder, KnowledgeRetriever, FusionModule from rag_gnn.utils import normalize_adjacency, compute_silhouette class TestGNNEncoder: """Tests for GNN encoder.""" def test_init(self): encoder = GNNEncoder(n_la...
7693095e968f6b5bf0b96e03f0e912f6d7856d32223cae349e212bff30eef51e
Python
8,540
237
""" Functions for removal of neuropil from calcium signals. Authors: - Sander W Keemink (swkeemink@scimail.eu) - Scott C Lowe Created: 2015-05-15 """ import numpy as np import numpy.random as rand from sklearn.decomposition import FastICA, NMF, PCA def separate( S, sep_method='nmf', n=None, maxi...
c370ae6d83c3feb24c30cac0ad0d20f1280b92238e28ce6bb0312ffb79272bc9
Python
8,540
263
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn as nn import torch.nn.functional as F from fairseq.modules.layer_norm import Lay...
6355d1f08c19cd3a36c49b0bc0406fb70b50ba2bf4667a245518760443062a19
Python
8,543
221
#!/usr/bin/env python3 """ Author: Ken Chen Email: chenkenbio@gmail.com """ import argparse import os import sys from tqdm import tqdm import numpy as np import h5py import pickle import torch import torch.nn.functional as F from torch.utils.data import DataLoader from collections import OrderedDict from torch.cuda.am...
e7a27dac3b53e134cacbb5f81f9bddb16c4f683286500536f395f6c7189604df
Python
8,546
223
#!/usr/bin/env python3 import numpy as np from scipy.special import logsumexp from tqdm.auto import tqdm from pgmpy.estimators.base import MarginalEstimator from pgmpy.factors import FactorDict from pgmpy.utils import compat_fns class MirrorDescentEstimator(MarginalEstimator): """ Class for estimation of a ...
79991db06b1392a4bed9d602302c5ca32d5d15dcccbf42919bf1bc2164edec5f
Python
8,548
235
import logging import os import pickle import re from functools import partial from typing import Tuple import haiku as hk import yaml from .log import H5MetricLogStream, MultiStreamMetricLogger, TensorboardMetricLogStream from .types import ModelDimensions, TrainState from .wf.envnet import EnvNet from .wf.orbformer...
e0957b333869136fa4c099f2b264dbd68f954ab63650a998251c27ed7bd12215
Python
8,548
266
import torch.nn as nn import torch from torch.nn import functional as F from utils.Geometry import LineSegement,LocalAxis,Geometry1D import numpy as np class Embedding: def __init__(self, HeavisideZero = 0): self.device = torch.device("cuda") if torch.cuda.is_available() else torch.devic...
cc14b0c0b2b2162e031b0773f827c5ff8c3799a390e11be024ea6db5f9a139f4
Python
8,550
222
from pathlib import Path import anndata as ad import numpy as np import pandas as pd from st_risk.models.base import BaseSpatialModelOutput from st_risk.models.cell2location_model import Cell2LocationRunner from st_risk.models.destvi_model import ( DestVIRunner, _destvi_sampled_proportion_summary, _normal...
03e122bbf7a6577159a16d45daac8012104e72dd0415ac0f33fed60c1bcb006a
Python
8,553
243
import logging import os import hydra import torch import torch.nn as nn import torch.nn.functional as F from einops.layers.torch import Rearrange from torch.utils.data import DataLoader, Dataset from .utils import Accuracy logger = logging.getLogger(__name__) def save_ckpt(model, path, model_class): ckpt = { ...
3581b45661b8e10ae40995fef5f0a4db9cc19089a04d2870eba79f5c47bce417
Python
8,553
234
import torch import torch.nn as nn import math class PositionalEmbedding(nn.Module): def __init__(self, d_model, max_len=5000): super(PositionalEmbedding, self).__init__() # Compute the positional encodings once in log space. pe = torch.zeros(max_len, d_model).float() pe.require_gr...
c2a27c1bd78aaf379c70a3771baccb6683ba2c883272a7b14f979b3f5a698303
Python
8,553
230
""" Routines to read in association file between genes and GO terms. """ __copyright__ = "Copyright (C) 2010-present, H Tang et al. All rights reserved." __author__ = "various" import gzip import os import sys from collections import defaultdict from .anno.factory import get_anno_desc, get_objanno, get_objanno_g_kw...
cbc692c733bec24e4c482f13f979166347b3c33e818ca9f8af9e2ea36e0c832f
Python
8,555
266
import torch.nn as nn import torch from torch.nn import functional as F from utils.Geometry import LineSegement,LocalAxis,Geometry1D import numpy as np class Embedding: def __init__(self, HeavisideZero = 0): self.device = torch.device("cuda") if torch.cuda.is_available() else torch.devic...
91b518745b006fb826b79ea439b0c6fe3ce8384888c1f6a147176eb0b37d59d2
Python
8,557
235
import pandas as pd import pdb # sys.path.append("../../corecode/") from build import * import matplotlib.pyplot as plt import seaborn as sns import numpy as np from scipy.stats import gaussian_kde import matplotlib.colors as colors import matplotlib.pyplot as plt plt.switch_backend('agg') from pathlib imp...
1374828938eac04f42a7c9e65c78314be3b67a8a5c32889e7b9bf9a69071e3ac
Python
8,562
179
import torch import numpy as np import torch.nn.functional as F import torch.nn as nn from utils import * from self_calibration import * from torch.fft import fftshift, ifftshift, ifft2, fft2 from fft_conv_pytorch import fft_conv, FFTConv2d dtype = torch.float32 class forward_model_wf_variant(nn.Module): def __in...
38f5ee87089fc2cdee0d598ee75b22a4375be091014a72e0945049268b087b35
Python
8,563
167
import json import tempfile import matplotlib.pyplot as plt from torch.autograd import Variable from torch.utils.data import DataLoader from pycocotools.cocoeval import COCOeval import time from tqdm import tqdm from dataload.cocodataset import * from eval.evaluator import Evaluator from utils.utils_coco import * from ...
50145670185c4a5e3fc3bb047b3bc60aeb7ba9157b80d656eef445d286c3faeb
Python
8,565
167
import json import tempfile import matplotlib.pyplot as plt from torch.autograd import Variable from torch.utils.data import DataLoader from pycocotools.cocoeval import COCOeval import time from tqdm import tqdm from dataloadR.cocodataset import * from evalR.evaluator import Evaluator from utils.utils_coco import * fro...
9c8720fdd4819c044635c7bf23677c925ad551767fb5d2218aa481afef812195
Python
8,566
150
import warnings from typing import List, Type, Optional, Tuple, Union from batchgenerators.utilities.file_and_folder_operations import join, maybe_mkdir_p, load_json import nnunetv2 from nnunetv2.configuration import default_num_processes from nnunetv2.experiment_planning.dataset_fingerprint.fingerprint_extractor imp...
9f0712f3ab7ddfa025d66542f1ed5c6cca1702a435ae8d4f6e9a070ed6d453f5
Python
8,566
197
from analysis.compute_modelFeatures import computePreTrainingFeatures, computePostTrainingFeatures ## wandb has to be setup from analysis.paperFigures import * # Plotting arguments plt.rcParams['font.family'] = 'Arial' plt.rcParams['pdf.fonttype'] = 42 plt.rcParams['ps.fonttype'] = 42 plt.rcParams['axes.spines.right...
0417588c0b5ef4d4ca31a28fa5d2bd3a2595ce978d335606b795d2b220e6af06
Python
8,568
176
"""A simple set of functions that train with a curses display.""" import json from typing import Any import h5py from bpreveal.internal import disableTensorflowLogging # pylint: disable=unused-import # noqa import tensorflow as tf import keras import numpy as np from bpreveal.callbacks import getCallbacks from keras.c...
a929ae03a47a8308a986d168d0f61b5f29f07e2d6c21e861937bca283033b606
Python
8,568
206
# Ranger deep learning optimizer - RAdam + Lookahead + calibrated adaptive LR combined. # https://github.com/lessw2020/Ranger-Deep-Learning-Optimizer # Ranger has now been used to capture 12 records on the FastAI leaderboard. #This version = 9.13.19A #Credits: #RAdam --> https://github.com/LiyuanLucasLiu/...
15b1350aa67f2f9daadc9ff3698802d3b99087fd855709fb1fc272b846c9ea7a
Python
8,569
235
# %% """Generate noise-robustness data for Fig. 3. The trained model weight files are assumed to already exist as model_<id>. For each model and noise level, Gaussian input noise is sampled several times; the stored value is the mean R2 over those repeated noise trials. """ from pathlib import Path import numpy as np...
baabd26e38a353cb9a863a074082d1c4f182edc1029588ba0875a8e7a2464212
Python
8,569
208
"""Per-food KAN interpretability (Paper #2), single quantification target = authentic fraction %. Mirrors kanfood.interpret_mango: compact (3,) B-spline KAN read off the SAME pipeline as the benchmark (preprocessing + group hold-out from <food>_meta.json), giving a closed-form symbolic equation, an accuracy-vs-complexi...
f46723e906e974201182019a1890dbdd5ec69450034042cadfc7f40a9e29142e
Python
8,573
242
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn as nn class RowSelfAttention(nn.Module): """Compute self-attention over rows of a 2D input.""" ...
9969c151ecfcfa4eb814b46e5f63a91870fef2a283d59b7bd25ad3fb4173e62a
Python
8,574
228
# Copyright 2021 DeepMind Technologies Limited # # 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 or agr...
9c2c43d9fab3cd55dfa94dd16926aedebb5efec74ddbabb03527d7cbd589b8ba
Python
8,577
300
""" Decorators for wrapping/unwrapping vtk objects passed/returned by a function. """ # Author: Oualid Benkarim <oualid.benkarim@mcgill.ca> # License: BSD 3 clause import inspect import functools from .wrappers.base import (wrap_vtk, _wrap_input_data, _wrap_output_data, _unwrap_input_dat...
3daf8a4975eccbf9289686f7d335729134e888ceda2c06fd022f39d2f86a2582
Python
8,579
226
import json import os import pandas as pd from mudata import MuData from scipy.stats import pearsonr, spearmanr from sklearn.metrics import mean_absolute_error as mae from sklearn.metrics import r2_score from scvi._types import AnnOrMuData from scvi.model._utils import REGISTRY_KEYS from scvi.model.base import BaseMo...
740982ca452ac3fb7375802b74af66ad9eba3debcd998ad6390589da6e6e9a08
Python
8,583
218
import itertools import networkx as nx from pgmpy.base import ADMG, DAG, MAG, PDAG from pgmpy.identification import BaseGraphicalIdentification from pgmpy.utils.sets import _powerset class Adjustment(BaseGraphicalIdentification): """ Given a causal graph, finds the adjustment set. This class implements...
e77f99ae2237d0b71a776e25adc4112c5f0739cd00c3e9aea88a266a377dceb4
Python
8,583
229
# /usr/bin/env python ''' Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md ''' import os import numpy as np import time import torch import CBIG_pMFM_basic_functions_example as fc import warnings def get_init(myelin_data, gradient_data, highest_order, ini...
13d91cbd281f667db38a3744e66142029d5b0f3e494dda4b11a6a008f9ca1262
Python
8,585
259
"""Predictions in the write shape annotation-hub accepts on `POST /save/`. Maps one record `infer` wrote onto one annotation object, carrying what only the predictions know. What the hub also requires and they cannot — the posting account, the project, the reference's own key and its bibliographic record — belongs to ...
8ea5c38587be3ae5a111e3d66cda0e6501628673a42c79a92a1dba6caa2bff15
Python
8,585
218
"""Pure unit tests for `d3text.models.ner.NERClassificationModel`. Every test here runs on CPU with tiny synthetic tensors and no data, network, or GPU. Methods are exercised through the `stub` fixture (see `tests/conftest.py`), which supplies only the attributes each method reads. """ import torch from torch.utils.d...
83ed98b63dc5c96481ce604291d8b636939c5a3086ed414009ea786b4407d4e1
Python
8,587
278
from scipy.spatial import KDTree import numpy as np from matplotlib.lines import Line2D from matplotlib.patches import Patch from .figure_Tools import point_value_PMF_1darray def nn_PMFs(ax, group, df, x0, x1, n_bins, n_boots): """Nearest neighbour PMF plot""" # get data arrays a = df.loc[df.Subtype == g...
8da2030a0fbf8029b8ed68a3c3e4ceb34c4fed277d06b4194c001baf2a0426b2
Python
8,588
291
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import bisect import os import pickle from abc import abstractmethod from collections.abc import Iterable, Iterator, Sequence from pathlib import Path from typing import Any, Generic, TypeVar import lmdb # type: ignore [import] from tqdm import...
c979d3e0a2f397750fb9a5ee3c621d4045cc942046008fb512498f8bcb5e4dbf
Python
8,589
212
# coding=utf-8 # Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team. # # 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://ww...
e87f2e5f057f952405994ff8d9cf6c6920a8030f5f852c0f65ba74debfb541aa
Python
8,590
268
from __future__ import annotations import shutil from pathlib import Path from typing import TYPE_CHECKING from typing import NoReturn from unittest.mock import PropertyMock import pytest import requests import responses from poetry.factory import Factory if TYPE_CHECKING: from cleo.testers.application_tester...
523e86fcde32106c36bf59df346b3309dd8201b5854f88ae49e18a90881eaa22
Python
8,591
214
# coding=utf-8 # Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team. # # 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://ww...
2d15b5c040232ddfc6df04f171cbd8e734c913c97ac35a824f1160cda2a0acd3
Python
8,592
195
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from fairseq.tasks import register_task from fairseq.tasks.multilingual_translation import MultilingualTranslationTask from fairseq.utils impo...
137dadb37b781fd5141580ec3df04c6736836112d94570adb74199b11f74e43b
Python
8,594
213
from collections.abc import Callable import networkx as nx import numpy as np import pandas as pd from sklearn.base import BaseEstimator, clone from pgmpy.base import DAG from pgmpy.causal_discovery._base import BaseCausalDiscovery from pgmpy.causal_discovery.bivariate_scores import BaseBivariateScore, get_bivariate_...
7f3b0b687ae5022168c171baa3978a41e3ddb03d148814cbcc264536c1c6392c
Python
8,597
233
from tape.models.modeling_utils import PairwiseContactPredictionHead from torch import nn, pdist, Tensor from torch.nn import MSELoss, CrossEntropyLoss, BCEWithLogitsLoss from torch.nn.modules.loss import _Loss from torch.nn.utils.weight_norm import weight_norm from torch.utils.data import Dataset from transformers imp...
14065adb12dc94f85a8eb9edd33c8dfd6243e7e035ca39dd2eb6c5d13dd889a9
Python
8,603
233
# /usr/bin/env python ''' Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md ''' import os import numpy as np import time import torch import CBIG_pMFM_basic_functions as fc import warnings def get_init(myelin_data, gradient_data, highest_order, init_para):...
4b49295eabbc484b98f132dc97ce08cee08facf989e1b5d00c9210339bac33a3
Python
8,610
210
import torch import torch.nn.functional as F import numpy as np dtype = torch.cuda.FloatTensor def apply_transform(img, theta, device): if img.ndim == 2: img = torch.unsqueeze(torch.unsqueeze(img, 0), 0) # (Batch, Channel, H, W) if theta.ndim == 2: # (2, 3) theta = theta.unsque...
93088e88e2cd208e9a78e314c8069b747a677687faee268f4b90b989addd045f
Python
8,620
194
# Do this here to suppress warnings before we import vak import logging import shutil import warnings from numba.core.errors import NumbaDeprecationWarning warnings.simplefilter('ignore', category=NumbaDeprecationWarning) import pandas as pd import tomlkit import vak from . import constants logger = logging.getLo...
a602653f7a4796d33ff2b54aa006a1317a350190f041a4f4a51405490af9d7cc
Python
8,622
207
import itertools import json import random import time from ast import literal_eval as make_tuple from multiprocessing import Process, Queue import numpy as np import psutil from sklearn import preprocessing from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier from sklearn.gaussian_process i...
a7b7810b07d2d3fb454e50e87ff679ed24858569149aca98480304d78933bf0a
Python
8,624
226
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
e2ef64b75aece5f448b34f8bfd80bcfb83d2c1793a2ff5dcc6256bfaa427d61a
Python
8,627
267
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import re import typing as tp from collections import Counter, deque from dataclasses import dataclass from bitarray import bitarray, util fr...
df762147b7c682f6ecf149d7f6949173e668b0463c8d2f7caed8e66838c3a5d6
Python
8,628
223
from anndata import AnnData from mudata import MuData # read data from ..data.datareaders import concat_data # preprocessing from ..preprocessing.preprocess_utils import preprocessing def DataProcess( adata_list, profile, data_type=None, sub_data_type=None, sample_col="batch", genome=None, ...
31a18ad47d5cb95e743cc0728f24fc12feccab9cb8544132429ce26d8176ce13
Python
8,631
204
# Copyright 2021 HIP Applied Computer Vision Lab, Division of Medical Image Computing, German Cancer Research Center # (DKFZ), Heidelberg, Germany # # 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...
168a8ef4835c2886a769a28e15ff9aacf52f4baebcfd3c4eaf2d836c378862e1
Python
8,632
232
from collections.abc import Callable from itertools import islice, permutations from math import factorial import numpy as np import pandas as pd from tqdm.auto import tqdm from pgmpy import config from pgmpy.base import DAG from pgmpy.causal_discovery._base import BaseCausalDiscovery from pgmpy.ci_tests import get_c...
7626ec4cb635c335b1f77b9a3b549f4b3fd78334f2064fd59bf6ab51fc23d06e
Python
8,634
269
# -*- coding: utf-8 -*- # # scikit-fmm documentation build configuration file, created by # sphinx-quickstart on Wed Feb 8 06:45:28 2012. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # ...
48adc9e767990db88803ca0b72c3bd6fc5648301d0060dba2eeae58e7d9ed0e1
Python
8,638
188
# -*- coding: UTF-8 -*- """ @Project: iDCF @File : train.py @IDE : PyCharm @Author : hjguo @Date : 2025/7/9 11:37 @Doc : Simulate pseudo-bulk data from single-cell data """ import anndata import numpy as np import pandas as pd from tqdm import tqdm from numpy.random import choice from typing import Union, Opt...
65473fc03f78005342dcd35f7476375d78d6d8988debc1824d2bd10941d27cd4
Python
8,638
226
"""Figure 3 panel C — L4/L5 misclassification analysis on S1 (Yu). Three groups of excitatory cells are compared: 1. L4 correct (true=E_L4, HIPPIE pred=E_L4) 2. L5 correct (true=E_L5, HIPPIE pred=E_L5) 3. L5→L4 misclassified (true=E_L5, HIPPIE pred=E_L4) Panels: Left — mean...
218926ccf5f476e5f3a6eff3994661207901dfb73564161893b2ea0f7f5bf4a8
Python
8,641
200
import argparse import numpy as np import bigstream.io_utility as io_utility from dask.distributed import (Client, LocalCluster) from bigstream.configure_bigstream import (configure_logging) from bigstream.distributed_transform import (distributed_apply_transform_to_coordinates) from bigstream.configure_dask import (C...
1d9655824a0b356b3c3e02731a3180871d90ccd378a5a282da32b945a91033d1
Python
8,643
225
# /usr/bin/env python ''' Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md ''' import numpy as np import time import torch import os import CBIG_pMFM_basic_functions as fc def get_init(gradient_pc1, gradient_pc2, highest_order, init_para): ''' Thi...
1bd0c050fbc1b56c8b134e443bb8629c3b90f3cc661fceea04a89c2622456595
Python
8,645
199
import os from textwrap import dedent from mdt.lib.nifti import load_nifti from PyQt5.QtCore import pyqtSlot, QObject, pyqtSignal from PyQt5.QtWidgets import QFileDialog from mdt.visualization.maps.base import SimpleDataInfo, MapPlotConfig from mdt.gui.maps_visualizer.main import start_gui from mdt.gui.model_fit.desi...
aefacf9d7a8f11aca59529f4969c602576907e7f7a870c76ac04ae93d4468b84
Python
8,647
228
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from fairseq.models import register_model, register_model_architecture from fairseq.models.nat import NATransformerModel def _s...
716ca5893433bd97423c8dffff510d8795449622050efd51451a46b859928ddc
Python
8,649
196
import shutil import time from tqdm import tqdm from dataloadR.augmentations import * from evalR import voc_eval from utils.utils_basic import * from utils.visualize import * from utils.heatmap import Show_Heatmap import config.cfg_lodet as cfg current_milli_time = lambda: int(round(time.time() * 1000)) ...
a41e33556ce42681ac796183406ead98cd4115279fe6747837d061798464f957
Python
8,652
232
""" download_singlecell_datasets.py -------------------------- Download the MS single-cell h5ad files from CELLxGENE Discover into data/. Two modes: (A) If metadata/ms_datasets_cellxgene.csv exists (produced by 01_query_...py), iterate its rows and download each h5ad via the Discover datasets endpoint. (B) F...
19460493dc8822fb1e2f05bcb33e36cc12c59cc2b00873a9bd6a898b9878d73b
Python
8,654
155
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'generate_protocol_update_dialog.ui' # # Created by: PyQt5 UI code generator 5.10.1 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtGui, QtWidgets class Ui_UpdateColumnDialog(object): def setupUi(sel...
42f00c330cdf33928140581e2619bf438d1b54252ff55d123caf1dcaf711d4ef
Python
8,654
217
import torch import torch.nn as nn import torch.optim as optim import torch.nn.init as init from torch.utils.data import DataLoader, TensorDataset, random_split class Sequential(nn.Module): def __init__(self): super(Sequential, self).__init__() self.layers = nn.ModuleList() def add(self, ...
33dd042c6532394e3e4e4caa6099f6979af3e9f515a0f5bd3bca25af2cc1f650
Python
8,655
259
# Source code: # https://github.com/zbmed-semtec/doc2vec-doc-relevance-training/blob/main/code/train_model/utilities.py # This file includes the modifications to the source codes according to this project! import tqdm import gensim import logging import numpy as np import pandas as pd from gensim.models.word2vec impo...
d3dc5d2678579f74ce4bbe7a2dc443fe1f56c050b996f2dd529d6e9bc3cdde68
Python
8,657
210
# coding=utf-8 # Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the Lice...