sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
922262d7fc26ce6966ea22902027903bdee5e9b62f51556a6c64e8ec2ffbbf1b | Python | 3,956 | 91 | """Create strings representing relationships on GO Terms.
+------- has 'part_of' relationship(s)
| +-- pointed to by a GO ID with a 'part_of' relationship
| |
V V
GO:0008150 L00 D00 .... .rdu biological_process
GO:0050896 L01 D01 ....... |
e7722b163d5c078a549902642eed7119e42044193bd22cea283606dbafaeb497 | Python | 3,956 | 117 | """Retrieve PubMed abstracts and full text content when available.
Feed the document database with abstracts and full text retrieved from PubMed.
"""
import asyncio
import itertools
from aiotinydb import AIOTinyDB
from aiotinydb.storage import AIOJSONStorage
from apiadapters import AsyncAPIAdapter
from apiadapters.... |
ffbe296d44ff5b19c4e4997ab634008c7fa9dc7fcc385a943cfd33524978120c | Python | 3,958 | 120 | import hydra
import random
import numpy as np
import torch
import os
import pathlib
from omegaconf import DictConfig
from yaml import safe_load
import pytorch_lightning as pl
from utils.diffusion_model.setup.setup import (
setup_callbacks,
setup_dataset,
setup_model,
setup_trainer,
)
@hydra.main(versio... |
63df79466ecc444e0849f1934392f095d1988e4480bbf875bef155a5612ba037 | Python | 3,959 | 90 | #!/usr/bin/env python
import sys
import pandas
import numpy
import numpy.testing
# This allows us to run an individual test as it's own 'program'. Very useful
# for debugging
if "DEBUG" in sys.argv:
sys.path.insert(0, "..")
sys.path.insert(0, "../..")
sys.path.insert(0, ".")
sys.argv.remove("DEBUG")
... |
1ad46d67324447f1e7c3c6941e59bf1222ea95b65645e1a7dcdb75dcfffa709a | Python | 3,961 | 103 | import logging
import lightning as L
import torch
from torch.distributions import Exponential, Normal
from torch_geometric.data import Batch
log = logging.getLogger(__name__)
class GraphAugmentation(L.LightningModule):
"""Perform graph augmentation for Novae. It adds noise to the data and keeps a subset of the ... |
5353752cf4e84b0993824cc7314af4a88b72c18b40c8836040ef24c1c46241f1 | Python | 3,962 | 124 | """Shared pytest fixtures.
We provide two kinds of fixtures:
* Synthetic-grid fixtures (``small_adata`` etc.) — fast, deterministic,
used for unit tests that only need the right shapes and a few clusters.
* Real-data fixtures (``simulated_adata``, ``dlpfc_adata``,
``dlpfc_image_path``) — derived from the files co... |
7c81f77078c6792f03bf0ea47c10e314adf601b3183c266821eee91ccd8fed3a | Python | 3,962 | 108 | import faiss
import numpy as np
import glob
import os
from typing import Union, List
from tqdm import tqdm
class FaissIndex:
"""
Wrapper for Faiss index
"""
def __init__(self,
index_path: Union[str, List[str]],
IO_FLAG_MMAP: bool = True,
nprobe: int ... |
f4e6fd81e21e794abf8b4301c2277bf3b4c7ece2329f4a53af9984c0066e400e | Python | 3,964 | 91 | """Two Paper-#1 deliverables ported to Paper #2: (i) the error-vs-concentration curve (KAN RMSE as a
function of adulteration level, with the IUPAC LOD marked as the reliable-detection floor) and (ii) the
detection confusion matrix on the independent hold-out. Uses the saved <food>_artifacts.npz (test
predictions, true... |
dbe88bb6f83918c64d5465245546894a26141eb689a92ef674f6193d460bb20c | Python | 3,965 | 115 | import logging
from typing import Callable, Union
import numpy as np
from openTSNE import TSNEEmbedding, affinity, callbacks, initialization
def art_of_tsne(X: np.ndarray, metric: Union[str, Callable] = "euclidean", exaggeration: float = -1, \
perplexity: int = 30, init_method: Union[str, Callable] ... |
4fba4a670d1e6bdcdaffaa51a6952888d3cdcedb7f01c1a7604bb5346265a9ec | Python | 3,968 | 122 | #!/usr/bin/env python3
"""
@file test_pc.py
@author Simon Yu
@date 02/10/2024
@brief Script for testing PC models.
"""
import argparse
import header
import logger
import math
import pc
import torch
import utility
import wandb
def initializeRunName(run_name = "", optimizer = "cccp"):
if run_name != "":
... |
653fc1f5718d31305b8269c28bb58a881ccd3313ab6fff8477e880ce53759c42 | Python | 3,968 | 79 | #!/usr/bin/env python3
"""Build donor x cell-type pseudobulk from the DEPOSITED LOG-NORMALISED Kaufmann matrix
(GSE144744 RNA_normalised: MatrixMarket 'real', 15354 genes x 497705 cells).
Because the deposited values are log-normalised expression (NOT counts), the statistically
appropriate pseudobulk summary is the ME... |
b403ed197b7d0a1d76a979167be61ababba4c7760eda993d274c7adc9d43a2f3 | Python | 3,968 | 93 | #!/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... |
72592ef5a8bcf34ea301fce2cd26a6af2eef47d512d1d2a5555c1b30780920d5 | Python | 3,970 | 118 | #!/usr/bin/env python3
"""Write the shared cross-language reference series.
python3 tests/fixtures/make_fixtures.py
The CSVs it produces are COMMITTED. Both the MATLAB and the Python suites read
these exact samples, which is what makes 1e-12 agreement a meaningful assertion
rather than a statistical hand-wave. Re... |
f1a75a36bc68baaee72739e1cd71388f3d23aa24975d170cd2cb1b9e18bd9182 | Python | 3,970 | 122 | from __future__ import annotations
import os
from typing import TYPE_CHECKING
import numpy as np
import pandas as pd
import pytest
from sparse import GCXS
from xarray import Dataset
from scvi.criticism import PosteriorPredictiveCheck as PPC
from scvi.criticism import create_criticism_report
from scvi.data import syn... |
759a86daeecc21daa0fd0b9a9ea13a943d886bbd5ad096f975b1b1c38ccbb8ce | Python | 3,971 | 153 | """FISSA functions to handle image and roi objects and return the right format.
If a custom version of this file is used (which can be defined at the
declaration of the core FISSA Experiment class), it should have the same
functions as here, with the same inputs and outputs.
Authors:
- Sander W Keemink <swkeemink... |
15e457666a666c098825abf79cefbd4465679e14856f47c21b09ecb6c1212d95 | Python | 3,976 | 119 | #!/usr/bin/env python
"""Import every module `[project.scripts]` names, one subprocess each.
Exit codes: 0 every entry point imported · 1 one or more did not, or
there was nothing to import. Rationale for the gate, and for one
subprocess per entry point: docs/how-to/run-the-checks.md (Imports).
"""
import argparse
im... |
8de6f7e4879b4e9a96d08b03fe5a8186c714efb4c4e75ee0fba0c3130c300c86 | Python | 3,977 | 110 | # 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 unittest
from argparse import Namespace
from collections import namedtuple
from pathlib import Path
import torch
from tqdm import tqdm... |
e399123740d14a4d18f066d499e9ff360b02d31db06c15d6e7fc9740d98285d2 | Python | 3,979 | 116 | from __future__ import annotations
import dataclasses
from typing import TYPE_CHECKING
from poetry.console.commands.self.self_command import SelfCommand
if TYPE_CHECKING:
from importlib import metadata
from poetry.core.packages.package import Package
@dataclasses.dataclass
class PluginPackage:
packa... |
282a92ce2593d5cc444e04e0fa25a2a141eb070e6f0f34e71ca32fd1fa111ac8 | Python | 3,981 | 114 | import os
import glob
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
from scipy.io import loadmat
from scipy.stats import wilcoxon
from scipy.interpolate import PchipInterpolator
# Figure dir
out_dir = '/home/shared/instruction_timing/figur... |
dde357817428bb79c351656ab3bbfd6530a503f8090a9c1468776c6eba8e84c4 | Python | 3,981 | 98 | from ... import options as opts
from ... import types
from ...charts.chart import RectChart
from ...globals import ChartType
class HeatMap(RectChart):
"""
<<< HeatMap >>>
The heat map is mainly used to represent the size of the value by color,
which must be used in conjunction with the visualMap comp... |
401fb51be59bc94c6a2fbd934d9a625374e522959d34fde91c4f144a5cbd3492 | Python | 3,982 | 117 | #!/usr/bin/env python
"""What does removing the class-negative label noise actually buy?
`class_negative_abstention` masks a document-level class negative wherever the
token-label store's dictionary matched that type anywhere in the text. This
reads two `evaluate` runs' logs — one with it off, one with it on, everythi... |
ea9457b60c43db715902336d2b6b6304542e132f39f84892031814d6641b68a4 | Python | 3,983 | 101 | import numpy
import numpy.testing
import unittest
from metax import Exceptions
from metax import MatrixManager
D = MatrixManager.GENE_SNP_COVARIANCE_DEFINITION
from . import cov_data
from . import SampleData
class TestMatrixManager(unittest.TestCase):
def test_invalid_data(self):
with self.assertRaises... |
9e07f7fa0f77ac9af12da15cdf7f2d79f96b99869d930af16dcd15c5905bf5ca | Python | 3,985 | 87 | import numpy as np
import pandas as pd
from pathlib import Path
# Define paths
base_dir = Path('/egor2/egor/MovieProject2')
task_name = 'backtothefuture'
output_per_subject_csv = base_dir / "bids_data/derivatives/group_analysis/backtothefuture" / f"{task_name}_per_subject_motion.csv"
output_mean_csv = base_dir / "bids... |
7cbb7f696c0a27129c8cff32364a2fa719040529a7c58815bd2e3775452f2d94 | Python | 3,991 | 75 | #!/usr/bin/env python3
"""O RMSE/σ = 0,178 do gap depende da grade de alpha?
O número que abre o manuscrito das perovskitas foi medido com o
`ridge_alpha_and_fit` do projeto, cuja grade era [1 … 1e6] — e em 29/07/2026 essa
grade foi reaberta para [1e-6 … 1e9] porque em vários alvos do QMOF o ótimo caía
ABAIXO do piso ... |
22f5b50ae11f1256541792759425c6900ab8b1a315d23e5ce8de9a83042da788 | Python | 3,992 | 116 | #!/usr/bin/env python
"""Score the dictionary linker on S800's hand-assigned NCBI taxids.
The one linking measurement in reach that is not circular. BRENDA supplies the
candidate entities and their surface forms; S800 supplies, per species span, a
taxid a human assigned against the NCBI taxonomy; and the bridge table
... |
de5b7bb0731b16c664b6034db4efb6454eb084713aead32a675980dd0e9c7d9c | Python | 3,992 | 121 | import numpy as np
from neuroCombat import neuroCombat
import pandas as pd
from scipy import stats
from scipy import special
def ccc(y1, y2, axis=-1):
e = 1e-12
mean_1 = np.mean(y1, axis=axis).reshape(-1, 1)
mean_2 = np.mean(y2, axis=axis).reshape(-1, 1)
var_1 = (np.std(y1, axis=axis)*... |
cd07a21164e4585d974afb5642c60a0aa33adeda3a95d120aa66e800c440db73 | Python | 3,994 | 98 | import multiprocessing
import shutil
from multiprocessing import Pool
import SimpleITK as sitk
import numpy as np
from batchgenerators.utilities.file_and_folder_operations import *
from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json
from nnunetv2.paths import nnUNet_raw
def copy_BraTS... |
de43a22dcdef12741dc4078a6763f9052db8bf70251bd8e9b5934dbd5e1b9642 | Python | 3,996 | 104 | import numpy as np
import matplotlib.pyplot as plt
def dfa(data, scales, order=1, plot=True):
"""Perform Detrended Fluctuation Analysis on data
Inputs:
data: 1D numpy array of time series to be analyzed.
scales: List or array of scales to calculate fluctuations
order: Integer of p... |
b75c6492b6bae923b29563b7508b783b061442729a5096bddd4a36a36ebbc1b0 | Python | 3,997 | 69 | import pytest
class TestLogLikelihoodCondGauss:
def test_score_manual_continuous(self, loglik_cond_gauss_manual_score):
assert loglik_cond_gauss_manual_score.local_score(variable="A", parents=("B_cat",)) == pytest.approx(
-1.8378, abs=1e-3
)
assert loglik_cond_gauss_manual_scor... |
cd84d5d17dc4473d31e857b7faedd4edb32798c56e3e305b0599c6f9acfba1b5 | Python | 3,997 | 110 | import inspect
import pytest
import vak.models.registry
from .conftest import (
MockModel,
MockEncoderDecoderModel,
MockModelFamily,
UnregisteredMockModelFamily,
)
from .test_definition import (
TweetyNetDefinition,
)
def test_model_family():
"""Test that :func:`vak.models.registry.model_fam... |
f0cba74cccdf8bc933aae935383b2b91bb667de194ef4df970ac51703f323a33 | Python | 3,997 | 104 | import loompy
import numpy as np
import os
import io
import pandas as pd
from scipy.io import mmread
import logging
import sys
import gzip
def read_vcf(path, compression: str = None):
"""
reads a vcf file into a pandas dataframe
"""
if compression is None:
with open(path, 'r') as f:
... |
acf02488a17ec8112cfac3a3a2b74653f20109a9f7e4a21725059a47e3e99bd6 | Python | 3,998 | 124 | """functions for plotting spectrograms"""
import matplotlib.pyplot as plt
from .annot import annotation
def spect(s, t, f, tlim=None, flim=None, ax=None, imshow_kwargs=None):
"""plot spectrogram
Parameters
----------
s : numpy.ndarray
spectrogram, a matrix
t : numpy.ndarray
vect... |
12772e814a86ed35ee9857f07c7eb5547505baa5334938ba98fdf1fb8e72c448 | Python | 4,000 | 146 | # 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
import os
import sys
import numpy as np
from sklearn.cluster import MiniBatchKMeans
import joblib
logging.basicConfig(
f... |
c05c0121f24aab67b4cdee4a8abbc4c569c76a3acf10a686fbe74c7424376812 | Python | 4,000 | 104 | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import math
import torch.nn.funct... |
4f3f648ea150de58d16670a44db8d512fda9603b8119ef9c5899f1a23c6d82b5 | Python | 4,002 | 120 | #!/usr/bin/env python3
# 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 argparse
import tempfile
import unittest
import torch
from fairseq.data.dictionary import Dictionary
from fair... |
054195f1ccdb8e4a0fa9ba289377a394ef78db5a1411e794b3ae635d5489fb26 | Python | 4,005 | 107 | # 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
import torch.nn as nn
def quant_noise(module, p, block_size):
"""
Wraps modules and applies quantization noise to the w... |
bfba48195c271559bf6175092cf10f80f69b16dbf2aa30e17e65c8c99814dcf7 | Python | 4,005 | 129 | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
import s... |
fa492baba05a2eadad1718de9512acaab85aa7840e0b878590b8ec9f624ea34c | Python | 4,005 | 129 |
import pytest
import vak.datasets
class TestCMACBench:
@pytest.mark.parametrize(
'split, window_size, target_type',
[
(
"train",
2000,
"multi_frame_labels",
),
(
... |
a5c6eca85d1594e4cf04cfb59056774543dbf616820f552055585264c1a97d3c | Python | 4,007 | 99 | #!/usr/bin/env python3
"""A little script to shift and combine bigwig tracks."""
import argparse
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal
import pyBigWig
import tqdm
def scanBigwigs(bwFname1: str, bwFname2: str, outFname: str) -> None:
"""Show a plot of the correlation between the t... |
ec6cad89e85161f15d2e1d2b7a1582a7fd7bef650c26656fd5a7278134952b55 | Python | 4,009 | 131 | import ml_collections as mlc
import copy
from rinalmo.data.alphabet import Alphabet
from rinalmo.data.constants import *
def model_config(name):
c = copy.deepcopy(default_config)
if name == "nano":
c.globals.embed_dim = 320
c.model.transformer.num_blocks = 6
c.model.transformer.num_h... |
5421ecbcd522aca5a6cee8de3c21491fa7b3983dca635b30443a198254eed1b2 | Python | 4,011 | 112 | from typing import Tuple
import numpy as np
import pandas as pd
from scipy.spatial.transform import Rotation as R
from utils.data.load import to_dataframe
# Utility Functions
def filter_nan_inf(array: np.ndarray) -> np.ndarray:
"""Replace NaN and Inf values with zeros."""
nan_mask = np.isnan(array) | np.isi... |
0d6cde3af4c52d04f493eb42febbeb56be797dd9e84245d21e45f7b02661e410 | Python | 4,012 | 100 | """GUI tests for the Resegment dialog (window_utils.open_resegment_window).
Tests verify the dialog opens correctly and contains the expected widgets
(Evfuncs panel + Segmentation Network panel, radio buttons, parameter
entries, comboboxes, status/progress).
"""
import pytest
from PyQt6.QtWidgets import (
QDialog,... |
3a62e14244f54726862d1d8be24a27e1132fe72b12dfe709ba530feb588f752a | Python | 4,015 | 128 | #!/usr/bin/env python3 -u
# 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 argparse
import os
import os.path as osp
import numpy as np
import tqdm
import torch
import sys
import faiss... |
93a457260fc2831e02771d638686d596620b36c0f5c2fba666c22b6ce2d19309 | Python | 4,015 | 108 | # 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 typing import Any, Dict, List, Optional
from torch import Tensor
from fairseq.models.transformer import Linear
from fairseq.models.tran... |
6851c89b9daed625c66460cb6b6540e55dbdd861930763edc7ca6eeb157c02ce | Python | 4,016 | 118 | # /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 torch
import scipy.io as sio
import CBIG_pMFM_basic_functions_main as fc
import warnings
def CBIG_pMFM_generate_simualted_fc_fcd(gpu_index=0... |
9f804304ef6537461fe0fc9b03a3b96892b93bfeea3140928f348b20cc4c748f | Python | 4,016 | 119 | """Figure 5 panel C — confusion matrices for all methods, Lisberger→Hull.
Row-normalised confusion matrices for HIPPIE, HIPPIE+Pretraining, NEMO,
PhysMAP, VAE, and VAE (no pretrain).
Outputs:
figures/29_figure_5_cross_species/panel_c_confusion.{svg,png}
"""
from __future__ import annotations
from pathlib import P... |
1472dbd9204f275dee062742ad2b00a2590efa21e3e251bb785e626b7603c880 | Python | 4,018 | 97 | """Plot OCE prediction vs xtb truth on the benzene H/F configurational set.
Generates a parity plot colored by fluorine count, with all 64 configs
predicted from a model trained on only the {0,1,5,6}-F subset (14 of 64).
"""
from __future__ import annotations
from pathlib import Path
import matplotlib
matplotlib.use... |
26ff6a9a381e86e946cfe6e095aa86f2d0e35fb8ec2c8ada05e4d0122471a33e | Python | 4,018 | 110 | #!/usr/bin/env python
import argparse
import os
import sys
from pathlib import Path
import anndata
import json
import gdown
import pandas as pd
import scipy
import shutil
import tempfile
def convert_data(out_dir):
# This is a google drive link to an annotated data set, as per https://stagate.readthedocs.io/en/la... |
9c10bc4c786907b2fa315168432c5984446551d62da251fb25e7b78a8bbe2f61 | Python | 4,019 | 140 | # -*- coding: utf-8 -*-
"""
Created on Fri Feb 28 13:08:08 2025
@author: hanna
"""
"""
Shared Space Alignment (SSA)
"We used the “shared space alignment” to measure the similarity between the
shared variance (or main shared variance) of Epoch A and Epoch B.
The shared space alignment is the frac... |
1ff93cce0b9affe25d0720188ff67bd3dc2891bcd9f0534addab542f19c05a5c | Python | 4,020 | 129 | # Copyright (C) 2025 ETH Zurich, Moritz Thürlemann, and other AMP contributors
import numpy as np
import os
import psi4
import argparse
import json
def read_xyz_file(file_path:str):
"""
Reads an XYZ file, skips the first two lines, and returns the rest.
Parameters:
file_path (str): Path to the XY... |
bce399b3e358aa8b7a304efca29e4de9fafdbf32075da9ffb5de64c4a807fe45 | Python | 4,021 | 85 | """Get descendant/parent counts for all GO terms in a GODag and broad L0 and L1 terms."""
from __future__ import print_function
__copyright__ = "Copyright (C) 2016-present, DV Klopfenstein, H Tang, All rights reserved."
__author__ = "DV Klopfenstein"
import collections as cx
from itertools import chain
from goatools... |
e98c3d453ab30d17ae1ab0126fc7b7252e5bc18a00bd876b6f3ec5c028623255 | Python | 4,022 | 89 | """Work with combinations of relationships, like *part_of* and *regulates*"""
from __future__ import print_function
__copyright__ = "Copyright (C) 2017-present, DV Klopfenstein, H Tang et al. All rights reserved."
from goatools.godag.consts import RELATIONSHIP_SET
class RelationshipCombos:
"""Work with combina... |
6c641a29d485cea1b13ca480f7b67a05c053ec935ec4d0e5aba844d38f1f65fb | Python | 4,025 | 83 | import pandas as pd
from BLRun.runner import Runner
class PearsonRunner(Runner):
"""Concrete runner for pairwise Pearson correlation GRN inference.
Runs entirely within the BEELINE conda environment; no Docker image is used.
The image field in the config should be set to 'local'."""
def generateInpu... |
ed649bcaa88183e95c3652acb2ee56825d42035d43c4e5a0050d17e06bf8867f | Python | 4,025 | 114 | import pytest
import torch
from torch import nn
from nnunetv2.nets.mobile_unet_v3 import MobileUNetV3
from nnunetv2.training.distillation.config import (
DistillationConfig,
get_baseline_config,
)
from nnunetv2.training.distillation.methods import build_method
def _loss(method, student, teacher):
target ... |
cca701c5dec8b8da83fa3d16ec6be8e8c0ca029e72753d4860a0b78b2322aa03 | Python | 4,029 | 125 | # 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 collections import OrderedDict
import torch
from torch.utils.data.dataloader import default_collate
from . import FairseqDataset
def ... |
e2399cafb08c221dafa02bc30ff7a4db4e258a16bc940aa1eba4b46db53c408d | Python | 4,029 | 79 | import matplotlib.pyplot as plt
from tqdm import tqdm
import numpy as np
import pandas as pd
import scanpy as sc
def cell_type_smoothing(adata, N_neighbors=15, weighted_smoothing=True, threshold=0.5,col_name = 'cell_type_from_scMulan'):
# 重新算一个nn,避免取的N_neighbors比画umap的时候选的参数大
sc.pp.neighbors(adata, n_pcs=10, n... |
f0bb48f13850c2943f5c011d289522a95b8221e0fb56952f97b68b4cf2d6b337 | Python | 4,029 | 106 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from typing import Optional, cast
import torch
from mattergen.diffusion.corruption.corruption import Corruption
from mattergen.diffusion.corruption.d3pm_corruption import D3PMCorruption
from mattergen.diffusion.corruption.sde_lib import ScoreFu... |
167fc2d66d573453d779cf400367952016f34492f45ceacc9b76d8875dc58108 | Python | 4,031 | 122 | #!/usr/bin/env python3
"""Generates the Neuroglancer logo in SVG format."""
import argparse
import numpy as np
def write_logo(path: str) -> None:
letter_cells = np.array(
[
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 1, 0, 0, 0, 0, 0, 1],
... |
64d2823d40f2e1cdb335f734bc04bb4e6d23ce3c6f247fb99405de121402e8b6 | Python | 4,031 | 97 | import numpy as np
import os
from matplotlib import cm
from matplotlib.colors import ListedColormap, LinearSegmentedColormap
autumn = cm.get_cmap('autumn', 256)
newcolors = autumn(np.linspace(0, 1, 256))
winter = cm.get_cmap('winter_r', 256)
winter_col = winter(np.linspace(0, 1, 256))
winter_col = winter_col[66:, :]
n... |
6df95e660b36ae9488d3d32b582d02af3c62e7b6231b0ea2eac03c7b36246f22 | Python | 4,032 | 124 | import unittest
from types import SimpleNamespace
from unittest.mock import patch
from GMXMMPBSA.exceptions import MMPBSA_Error
from GMXMMPBSA.make_top_amber import CheckAmberTop
def _files(**overrides):
values = {
'complex_top': 'complex.prmtop',
'complex_trajs': ['complex.mdcrd'],
'comp... |
7330c35875112aee7b11fcc179e4cc33ab65149c5427549038d4fa1594341a3d | Python | 4,034 | 91 | from pathlib import Path
import os
import sys
import subprocess
import argparse
from datetime import datetime
import logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s [%(levelname)s] %(message)s',
handlers=[logging.FileHandler('debug.log'), logging.StreamHandler()]
)
logger = logging.get... |
77d2790e6b76fb732797cbaea8877affa8f2c20d3b8bd8e06ddb6bfbe9cc8d50 | Python | 4,036 | 98 | """Quick test: does adding 4-figures (dihedrals) help in-domain isomer
ranking and the C6H14 transfer ranking that's the current OCE limit?"""
from __future__ import annotations
from collections import defaultdict
from pathlib import Path
import numpy as np
from scipy.stats import kendalltau, spearmanr
from oce.atom... |
2cc9b1d59f8c2a4466cd253b1582a44bba337f899751eaf9d4ee41188830fd2a | Python | 4,038 | 92 | #!/usr/bin/env python
# @license
# Copyright 2020 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 applicab... |
9f8b4c3fe4148e480027f79b3d98e804eb982cd12dad220610ffc798d9be3d7c | Python | 4,039 | 112 | from pathlib import Path
import numpy as np
import nibabel as nib
from tqdm import tqdm
import os
import torch
import torch.nn.functional as F
def block_ind(mask, sz_block=32, sz_pad=0):
# find indices of smallest block that covers whole brain
tmp = np.nonzero(mask)
xind = tmp[0]
yind = tmp[1]
zind = t... |
e8cb724209353bb285d954f61f49229f4ad1749851ff3f8058c0a7317b60ddf0 | Python | 4,041 | 115 | # 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 argparse
import tempfile
import unittest
import torch
from fairseq.data.dictionary import Dictionary
from fairseq.models.lstm import L... |
dbfb450ee62d6fc386fd6d5dd6029150e0ab7dbb756f65dd773d3e67130b3411 | Python | 4,042 | 105 | from collections.abc import Hashable
from math import lgamma
import numpy as np
from scipy.special import gammaln
from pgmpy.structure_score._base import BaseStructureScore
from pgmpy.utils import encode_columns, get_state_counts_array
class BDeu(BaseStructureScore):
r"""
BDeu structure score for discrete B... |
9cc5c36fc0bb201df5926ce42e242f95f7615b767f6d196490c59713fd272a77 | Python | 4,043 | 135 | import boto3
from datetime import datetime, timezone
class JobDefinitionException(Exception):
pass
def format_voluseg_kwargs(voluseg_kwargs: dict) -> dict:
parameter_to_env_var = {
"detrending": "VOLUSEG_DETRENDING",
"registration": "VOLUSEG_REGISTRATION",
"opts_ants": "VOLUSEG_REGIS... |
85a300b7871e0e9d00ed7bc56f4d38568e31f04700b41051ba1ecc9efc0f7e03 | Python | 4,044 | 106 | """Reads a Annotation File in text format with data in id2gos line"""
import sys
from ..base import logger
from .annoreader_base import AnnoReaderBase
from .init.reader_idtogos import InitAssc, _parse_go_terms
__copyright__ = "Copyright (C) 2016-2019, DV Klopfenstein, H Tang. All rights reserved."
__author__ = "DV K... |
c59f45a9aaf23e164e5d26eb0a498f75252880d20363333e7aba344c714e1f62 | Python | 4,044 | 135 | import json
from dataclasses import dataclass, field, asdict
from pathlib import Path
from typing import List, Optional, Union
from typing_extensions import Self, Literal
from datasets import Dataset
@dataclass
class DataTable:
"""
The data structure for a single-cell data table.
"""
name: str
d... |
df3505e00ab5a5ef1d720efa4dcb4d6515c9d2244ee6015c9e38e44d7406d666 | Python | 4,044 | 117 | import pandas as pd
from skbase.base import BaseObject
from skbase.lookup import all_objects
class BaseSupervisedMetric(BaseObject):
"""
Base class for all metric classes in pgmpy that require ground truth causal graph.
"""
def evaluate(self, true_causal_graph, est_causal_graph, **kwargs):
""... |
a24fda3e897fd6e010da1758c3a10bbd70ae57e1a1f9bb08a8e9b1ebae1dd1e7 | Python | 4,045 | 103 | from typing import Tuple
from batchgenerators.utilities.file_and_folder_operations import save_json, join
def generate_dataset_json(output_folder: str,
channel_names: dict,
labels: dict,
num_training_cases: int,
f... |
59186af21f8aa8bb294b04c6c231c7775d52368e0143fbaf3ef23e66989607b7 | Python | 4,046 | 112 |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
from tractseg.data.data_loader_inference import DataLoaderInference
from tractseg.libs import peak_utils
def get_seg_single_img_3_directions(Config, model, subject=None, data=None, scale_... |
8e4e81bb3ad431d7c428b5db5b259448853d961389f7ead978df51e5249e9fe4 | Python | 4,047 | 117 | import pytest
from rnalysis import __attr_file_key__, __biotype_file_key__
from rnalysis.filtering import Filter
from rnalysis.general import *
def test_parse_wbgene_string():
string = (
' WBGene WBGenes WBGene12345678, WBGene98765432WBGene00000000\n the geneWBGene44444444 '
'daf-16 A5gHB.5 /// W... |
d141154c5b82ed37de2926597c6d044e40d9aef4c4ea00dd67556d6872114369 | Python | 4,047 | 155 | #
# Copyright 2017-2023 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with
# Sandia Corporation, the U.S. Government retains certain rights in this software.
#
# See LICENSE for full license details
#
import sys
import numpy as np
sys.path.append("../..")
from simulator.cores.analog_core import Ana... |
abacdc351eb270437520a66adb83a9dcbdd31e1c9927077e78bc2cb75b2a31df | Python | 4,048 | 83 | """Import-regression guards: the heavy scientific stack must stay lazily imported.
``import rnalysis.filtering`` used to cost ~3.5s warm because seaborn, scikit-learn and pandas were
imported at module level (issue #257). Every script, notebook kernel, CI test process and -- worst of
all -- every ``spawn`` multiproces... |
fdd26b902b0e4ab83ef865ea67434a750d07c298099900797e2e1776ec9fc4e5 | Python | 4,048 | 89 | import os
import pandas as pd
from BLRun.runner import Runner
class SINCERITIESRunner(Runner):
"""Concrete runner for the SINCERITIES GRN inference algorithm."""
def generateInputs(self):
'''
Function to generate desired inputs for SINCERITIES.
If the folder/files under self.input_di... |
c10b545d81ef13783c2028c8c2a84ea95356871c452c2b307a1c486d569fe8ab | Python | 4,053 | 127 | import numpy as np
import mne
from mne import make_ad_hoc_cov
from mne.datasets import sample
from mne.simulation import (
simulate_sparse_stc,
simulate_raw,
add_noise,
add_ecg,
add_eog,
)
def load_simulated_raw():
"""Load simulated raw data.
This function returns a modified version of... |
078d3c3e1942b7f768d990a43af1f3dfc26fef92d42832e3382eac2f08d10366 | Python | 4,054 | 101 | """The batch contract: what `get_batch_loader` hands the model.
Nothing used to drive the loader, so the collate that sits between the dataset
and the model was never pinned — and the models were written against the shape
torch's `default_collate` happened to produce (a phantom leading dim on every
field) rather than ... |
3698bed05f75b75a6e069181f938a5a216c685f7e9148418c07f52753929a155 | Python | 4,055 | 103 | """GUI tests for the Cluster dialog (window_utils.open_cluster_window).
Tests verify the dialog opens correctly with dataset creation widgets,
UMAP parameter entries, cluster/Dash/replace buttons.
"""
import pytest
from PyQt6.QtWidgets import (
QDialog, QRadioButton, QLineEdit, QComboBox, QPushButton,
QCheckBo... |
19d7d0fe2294daaa26f302f9585fb86093d8f59841932fa017ae0efe10faa1df | Python | 4,056 | 143 | #!/usr/bin/env python
# ENCODE DCC pseudo replicator wrapper
# Author: Jin Lee (leepc12@gmail.com)
import sys
import os
import argparse
from encode_lib_common import (
assert_file_not_empty, get_num_lines, log, ls_l, mkdir_p, rm_f,
run_shell_cmd, strip_ext_ta)
def parse_arguments():
parser = argparse.Ar... |
0d22cf2b8b862a1adcefd6e599d5e3a5aed3981335100e98a64684081c4d804b | Python | 4,057 | 94 | import numpy as np
import torch
from pytorch_grad_cam.base_cam import BaseCAM
from pytorch_grad_cam.utils.find_layers import find_layer_predicate_recursive
from pytorch_grad_cam.utils.svd_on_activations import get_2d_projection
from pytorch_grad_cam.utils.image import scale_accross_batch_and_channels, scale_cam_image
... |
30a1dba16606122173d12b9a548c3bbc4d0a1ad54db79d7c8aeeaed1d194dc47 | Python | 4,057 | 70 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This module contains the constants that are used in the moosez.
.. moduleauthor:: Lalith Kumar Shiyam Sundar <lalith.shiyamsundar@meduniwien.ac.at>
.. versionadded:: 3.0.0
"""
ALLOWED_MODALITY_CONFIGURATIONS = {'CT': [None],
'PT': ... |
abbfe907450dc7a47cf880a262fdf0510ff09d089d6b8be8cbb5a41c05be4b56 | Python | 4,057 | 135 | import numpy as np
import pytest
from scvi.data import synthetic_iid
from scvi.external import Decipher
from scvi.external.decipher.utils import Trajectory, rotate_decipher_components
@pytest.fixture(scope="session")
def adata():
adata = synthetic_iid()
return adata
def test_decipher_train(adata):
Deci... |
b2b54826a0a5efbefd971c0d718da0e555fcc791d2e04f8d532bd81222116db5 | Python | 4,057 | 116 | # /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 torch
import CBIG_pMFM_basic_functions as fc
def CBIG_mfm_test_desikan_main(gpu_index=0, weight=0.5):
'''
This function is to implem... |
dfe454aff1a6e36e7cec47a560eaead9195587a87826355c6bee948caebd0437 | Python | 4,057 | 116 | # /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 torch
import CBIG_pMFM_basic_functions as fc
def CBIG_mfm_test_desikan_main(gpu_index=0, weight=0.5):
'''
This function is to implem... |
f77147f06c11db7c359ba3566797079c7b9e0b077d9d2fb26518e8ccc680393a | Python | 4,057 | 116 | # 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 __future__ import absolute_import, division, print_function, unicode_literals
from collections.abc import Iterable
from itertools import... |
10e34f1f51bb905f8a5b7cfe1bc1046cde27899c7631a8ef8c7d95a7aadf0b99 | Python | 4,058 | 117 | #!/usr/bin/env python3
"""
Author: Ken Chen
Email: chenkenbio@gmail.com
Date: 2022-12-09
"""
import argparse
import os
import sys
import warnings
import h5py
import numpy as np
from utils import load_fasta, get_reverse_strand, encode_sequence
from typing import Any, Dict, Iterable, List, Literal, Optional, Tuple, Uni... |
ed648e75daab408e79d1a5abc20dd1f880c226c43069f75f207fa624e50d9e0d | Python | 4,058 | 107 | """Deprecated compatibility shim over :class:`pgmpy.causal_discovery`'s constraint-based machinery."""
from collections.abc import Callable
from sklearn.base import clone
from pgmpy.base import UndirectedGraph
from pgmpy.estimators import StructureEstimator
from pgmpy.utils._warnings import _warn_external
class Ba... |
f43eede95791601c572d2a653c2276b01d9e2c8f7844f4592187658f5e2b5257 | Python | 4,058 | 102 | import numpy as np
import matplotlib.pyplot as plt
from joblib import Parallel, delayed
from tqdm import tqdm
import os
import sys
import itertools
n_proc = int(sys.argv[1])
def logistic_func(s, s_0=0, k=1, L=1, noise_level=0, max_L=5):
if noise_level > 0:
r = L / (1 + np.exp(-k * (s - s_0))) + np.random.... |
c00b8cabb6ad96bdbaaf31bef6a7d161092fe0ee5c5f5511f3431d18558c5617 | Python | 4,059 | 120 | from torch.utils.data import DataLoader
import lightning.pytorch as pl
from typing import Union, Optional
from pathlib import Path
from rinalmo.data.alphabet import Alphabet
from rinalmo.data.downstream.secondary_structure.dataset import SecondaryStructureDataset
from rinalmo.utils.download import download_spot_rna... |
cd079211b123442db59b007a09ddab752d32340e8e1dda7850f8a279aa3ca6de | Python | 4,059 | 95 | import logging
import os
import random
import tempfile
import unittest
import pysam
from medaka.align import initialise_alignment
from medaka.common import get_bam_regions, Region
from medaka.features import BAMHandler, CountsFeatureEncoder, ReadAlignmentFeatureEncoder
from medaka.prediction import DataLoader
class... |
97de133c583bdec7a4e09f3e45c73e3c79afa99f63244745a33080c55d7a23d1 | Python | 4,062 | 133 | def nn_PMFs(ax, group, df, x0, x1, n_bins, n_boots):
"""Nearest neighbour PMF plot"""
# get data arrays
a = df.loc[df.Subtype == group + "a", ["Root_x", "Root_y", "Root_z"]]
b = df.loc[df.Subtype == group + "b", ["Root_x", "Root_y", "Root_z"]]
c = df.loc[df.Subtype == group + "c", ["Root_x", "Root_... |
6717258ebdb09cc300b168e3b4589bc6d2c42a94c7fb1f470da56e5006adeaa0 | Python | 4,063 | 61 | import sys
import os
curPath = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.abspath(curPath))
import run_finetune
import data_processor
import run_evaluate
import argparse
import torch
import pandas as pd
def create_parser():
parser = argparse.ArgumentParser()
parser.add_argument('--inpu... |
e47f8df83cd99ae22496146a9de62a6bf48e1f0a92e137fcb14eb09115d240ce | Python | 4,063 | 102 | # _*_ coding: UTF-8 _*_
# Version information START --------------------------------------------------
VERSION_INFO = \
"""
Author: ZHANG YUBO
Version-01:
2019-01-27 convert sequence (phylip format) generated by seqgen to geno
Version-02:
2019-11-04 convert sequence (phylip format) to... |
460c49ba4e74dafa20bf1c4f541124d853ee8bf2d974f8753ed63dea552381a5 | Python | 4,064 | 135 |
def nn_PMFs(ax, group, df, x0, x1, n_bins, n_boots):
"""Nearest neighbour PMF plot"""
# get data arrays
a = df.loc[df.Subtype == group + "a", ["Root_x", "Root_y", "Root_z"]]
b = df.loc[df.Subtype == group + "b", ["Root_x", "Root_y", "Root_z"]]
c = df.loc[df.Subtype == group + "c", ["Root_x", "Roo... |
3eb0afe408978b79f334b185035d749f71bde8f18b2294ffa034f6a971d7285d | Python | 4,066 | 117 | # /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 torch
import CBIG_pMFM_basic_functions_main as fc
import warnings
def CBIG_mfm_test_desikan_main(gpu_index=0):
'''
This function is ... |
8d36bb2a14e897aa30d6d39cd5789cd85e65916029f7ca5838a96fab667648bf | Python | 4,066 | 88 | import os
import cv2 as cv
import numpy as np
import time
import gc
import sys
def normalization(img):
a, b = -0.015, 0.002
min, max = np.min(img), np.max(img)
k = (b - a) / (max - min)
normalized_img = a + k * (img - min)
return normalized_img
def single_serial_spatialresponse(target_... |
16687a4de2587b00264a5b15d3c52972501e2006dfa484cb2c28b7ec0633c812 | Python | 4,068 | 109 | #!/usr/bin/env python3
import pickle
import argparse
import os
import sys
import numpy as np
import pandas as pd
import torch
from torch import Tensor
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader, Dataset, Subset
from transformers import BertTokenizer, BertTokenizerFast... |
96356c9949880cd1a73a96e0a043a660be9257e28020366835f8802db2a1acfd | Python | 4,068 | 120 | # Copyright 2015 Google Inc. 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.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... |
37999ced438484a5a63a523ef95c61f91f69995c7cf647927c0a9d903f4da1f1 | Python | 4,070 | 117 | import torch
def compute_hyper_elastic_loss(
input_coords, output, batch_size=None, alpha_l=1, alpha_a=1, alpha_v=1
):
"""Compute the hyper-elastic regularization loss."""
grad_u = compute_jacobian_matrix(input_coords, output, add_identity=False)
grad_y = compute_jacobian_matrix(
input_coords... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.