sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
616830d4905937dfc5ed6e6f94ae2075b4344308afaa13365f2af1f772e3e089 | Python | 4,379 | 87 | """mesh load/save.
just a thin wrapper around trimesh so nothing else in this package has to
import trimesh directly - keeps the mesh library swappable if I ever need to.
replaces the old registration/write_ply.py and nicp/write_ply.py (three
hand-rolled ASCII PLY writers between the two of them, for some reason) plus... |
448b0fc0373f71ca41251e3b0cbd047e3f6b2d9c7a47fc35ecafa1ff5d6bff7d | Python | 4,381 | 130 | import numpy as np
from scipy.io import savemat
def create_mat_file(filename, *args):
temp_data = []
temp_comm = []
args = list(args)
while args:
if args[0] == 'channel':
data = np.array(args[1])
ts_fs = np.array(args[2])
name = args[3]
unit = a... |
2b88d0a96cc5e148773792d4cc6c299115c2cd3b8299e7268b0b84726786d3b8 | Python | 4,384 | 92 |
from copy import copy
import pandas as pd
class Input:
def __init__(self, Table, pdata,
quant_strategy='LFQ intensity'):
""" MaxQuant output
MaxQuant output is composed by a ProteinGroup.txt file and it contains
several parameters that can be used to filter the data.
... |
3506cc93b890285e8022b4ced66eccc3f29ff73ada98d8580eb935599e4056b9 | Python | 4,384 | 81 | import mne
import mne_rsa
import os.path as op
import numpy as np
import pandas as pd
from skimage import io, color
from mne.minimum_norm import (make_inverse_operator, apply_inverse_epochs)
from config_FaceName import MEG_data_path,group_name,Ids,stim_folder,stimuli_list,RSA_data_path,MRI_data_path
rsa_metri... |
da8fc461c40421c81e902a73f7a4e0c1729a6a11fd778f25c86225469cbf9960 | Python | 4,385 | 178 | from langchain_classic import document_loaders
EXPECTED_ALL = [
"AcreomLoader",
"AsyncHtmlLoader",
"AsyncChromiumLoader",
"AZLyricsLoader",
"AcreomLoader",
"AirbyteCDKLoader",
"AirbyteGongLoader",
"AirbyteJSONLoader",
"AirbyteHubspotLoader",
"AirbyteSalesforceLoader",
"Airby... |
3ac0a197e29c40aea3ed6c3023ad18a2a91db8059039bc920533a927ea41274e | Python | 4,386 | 100 | import numpy as np
import networkx as nx
import torch as pt
#import torch_geometric as ptg
import pytorch_lightning as ptl
import torch
from torch.nn import Sequential as Seq, Linear, ReLU
#from torch_geometric.nn import MessagePassing
from pytorch_lightning import LightningModule
from torch.optim.adam import Adam
from... |
f399b060dbe1876e34f3aa300e6680c53d9162d33984314d9d0d3d1cf9487f68 | Python | 4,386 | 129 | """Pass input through a moderation endpoint."""
from typing import Any
from langchain_core.callbacks import (
AsyncCallbackManagerForChainRun,
CallbackManagerForChainRun,
)
from langchain_core.utils import check_package_version, get_from_dict_or_env
from pydantic import Field, model_validator
from typing_exte... |
d46c0fe1a9be6e0623f2faef1072e3cdbfe7755481aaccd63f25b557e5ef8d1a | Python | 4,388 | 151 | """
Copyright (c) 2021 Chris Pollard and Philipp Windischhofer
an implementation of the partially convex neural networks
introduced in https://arxiv.org/abs/1609.07152
"""
import torch
import numpy as np
def Softplus(threshold=20, zeroed=False, symmetric=False, device="cuda"):
# can be exported by onnx_gr... |
ed90bc0b8de775f20343813a6a89f9c10d3add501feff2a7c78547ad68d2de13 | Python | 4,389 | 145 | import torch
import torch.nn as nn
import numpy as np
from einops import rearrange, repeat
class MultiHeadAttention(nn.Module):
def __init__(self, embedding_dim, head_num):
super().__init__()
self.head_num = head_num
self.dk = (embedding_dim // head_num) ** (1 / 2)
self.qkv_layer... |
3b8dd7c697bf9960c229598e844ccec97917c464319f3925a7f2878a05827c99 | Python | 4,390 | 117 | from collections import defaultdict, Counter
from sklearn.metrics.pairwise import cosine_similarity
from scipy.cluster.hierarchy import dendrogram, linkage, fcluster
from scipy.spatial.distance import pdist
from sklearn.cluster import KMeans
from sklearn import metrics
from sklearn.linear_model import LogisticRegressio... |
bea277e15ccb5726da45eeec9aaa0cdb87a9da379b40a5daa8a93b26c575142f | Python | 4,394 | 156 | import sys
import torch
import networkx as nx
import networkx.algorithms.components.connected as nxacc
import networkx.algorithms.dag as nxadag
import numpy as np
def pearson_corr(x, y):
xx = x - torch.mean(x)
yy = y - torch.mean(y)
return torch.sum(xx * yy) / (torch.norm(xx, 2) * torch.norm(yy, 2))
def load_on... |
a14c028536bcc46ed857a992798b52c748e4d951993901753682aa9844bbeaa0 | Python | 4,396 | 99 | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@Description: :
@Date : 2022/06/15 00:00:10
@Author : Zilan Yu
@version : 1.0
'''
import pandas as pd
import os
root_filter_datasets = "../filter_datasets"
filter_iedb_filepath = os.path.join(root_filter_datasets, "filter_iedb.tsv")
filter_vdjdb0... |
bd0aeb36d8fb311b0b77e106a8a8c16249d4baf358e8da6fcbdfa1feb3b4fd8b | Python | 4,400 | 120 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for d... |
85064a8fc2bde6804ac7e89c8e42557708b0a554b285c032a7e84a404b44ddd3 | Python | 4,401 | 112 | # Picks 2K Infinium 1 probes
from __future__ import print_function
import sys
import gzip
from collections import defaultdict
import operator
def main():
if len(sys.argv) != 7:
print("Usage: python pickProbesInfinium1.py <file of sites already picked> <all probes file> <EPIC manifest file> <num Infinium 1... |
e792f28685050186240f636c22348e90710cb9401659ca17a4b75ff68da7f1ac | Python | 4,401 | 120 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2026 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for detai... |
4f4fc05f48f59685e897309a083f9286a275cd83764576103f6c39c9381a78cd | Python | 4,404 | 129 | # Burrowed from https://github.com/pytorch/pytorch/blob/master/torch/optim/swa_utils.py
# modified for the DomainBed.
import copy
import torch
from torch.nn import Module
from copy import deepcopy
from tqdm import tqdm
class AveragedModel(Module):
def __init__(self, model, device=None, avg_fn=None, rm_optimizer=Fa... |
897fcd4fdf4245729f422bc9b9ed775916d905425bc3d925ba4e615a3a25d0ce | Python | 4,406 | 94 | # Analyses without using the concerned words for each concept
# Copyright (c) 2021 Laurent Caplette
import numpy as np
from sklearn.decomposition import PCA
import h5py, json, pickle
np.random.seed() # randomly initialize the seed
homedir = '' ### path of home directory
nwords = 10
ncomps_feat = 213
nperms = 1000
... |
72ed94cddc34b3f4474c498b9edabd511e193e641e7a6d2f81b7f70a769b0383 | Python | 4,408 | 88 | from mimic3benchmark.readers import InHospitalMortalityReader
from mimic3benchmark.readers import DecompensationReader
from mimic3benchmark.readers import LengthOfStayReader
from mimic3benchmark.readers import PhenotypingReader
from mimic3benchmark.readers import MultitaskReader
from mimic3models.preprocessing import D... |
8c3de8e0da2cf06ba696b92252464f7bffa7b2386426ee47eb9a4be1b557a988 | Python | 4,408 | 122 | #!/usr/bin/env python
"""
Run perses
"""
def load_molecules(filename, append_warts=False):
"""
Read molecules from the specified file, appending warts (suffixes) to molecules with identical names if desired
Parameters
----------
filename : str
The file name from which to read molecules in ... |
8dd051e07f2a36de6c8a49bd4d0b09a73cbe436d6058779c019ac97ef17e7779 | Python | 4,411 | 132 | from pathlib import Path
import numpy as np
import pytest
import torch
import torch.nn.functional as F
import chroma
from chroma.data import Protein
from chroma.layers import graph
from chroma.layers.structure import hbonds, protein_graph
@pytest.fixture(scope="session")
def XCS():
repo = Path(chroma.__file__).... |
a2a4b1629a908d76fa56a8eb7d2f0c976c21bc8666de92796eaae109e4b1fb4b | Python | 4,411 | 154 | """Callback Handler streams to stdout on new llm token."""
from __future__ import annotations
import sys
from typing import TYPE_CHECKING, Any
from typing_extensions import override
from langchain_core.callbacks.base import BaseCallbackHandler
if TYPE_CHECKING:
from langchain_core.agents import AgentAction, Ag... |
168fc525033248feb9a601bd3232db6894ee9f3de58c611672cd5941b2bbdd8f | Python | 4,413 | 127 | """Hypothetical Document Embeddings.
https://arxiv.org/abs/2212.10496
"""
from __future__ import annotations
import logging
from typing import Any
from langchain_core.callbacks import CallbackManagerForChainRun
from langchain_core.embeddings import Embeddings
from langchain_core.language_models import BaseLanguageM... |
e279b57670fd0b63d6d0b3a7c35b90ccfb3763f623544ec09ea3184cb2d87fca | Python | 4,413 | 117 | import argparse
import os
import shutil
import h5py
import nibabel as nib
import numpy as np
import SimpleITK as sitk
import torch
from medpy import metric
from scipy.ndimage import zoom
from scipy.ndimage.interpolation import zoom
from tqdm import tqdm
# from networks.efficientunet import UNet
from networks.net_fact... |
2400eaa97803463b037c20d1554710a621c5953aa7a1234eeb58b56fd0ff4f28 | Python | 4,415 | 134 | import numpy as np
def random_Cij_und(V, E):
"""Generate undirected binary random network:
Args:
V (int): number of vertices
E (int): number of edges
Returns:
Cij [array]: undirected, binary random network with 0 diagonal
"""
indmat = np.triu(np.logical_not(np.eye... |
24cf411b766aae8ad3a4b701ad4bfebf8fb40946a8751a931fc78012e9e542d7 | Python | 4,416 | 168 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import division, print_function
import argparse
from time import time
# import pylab as pl
import nibabel as nib
import numpy as np
DESCRIPTION = """
Pick the best odf ratio for each voxel based on AIC.
"""
EPILOG = """
Michael Paquette, MPI CBS, 2... |
8bdd97974a406847ded4fce2b8d93c15f64d085b7995ff9484cc63d9aedce16e | Python | 4,418 | 124 | from __future__ import annotations
from collections.abc import Sequence
from copy import deepcopy
from typing import Any
from langchain_core._api.deprecation import deprecated
from langchain_core.callbacks import Callbacks
from langchain_core.documents import BaseDocumentCompressor, Document
from langchain_core.utils... |
1eabe6138f2dc5c3a14ec4c25cdfd806a4db7a7977b2dbc0831976c19e560cf8 | Python | 4,420 | 102 | import logging
import os
import socket
import sys
import pandas as pd
from configs.configs import get_config_dict
from helpers.hcp import get_human_connectome_project_subjects, get_human_connectome_project_subjects_phenotypes
from helpers.morphometricity import variance_component_model, get_phenotype_array, get_covar... |
f42be3199bfd61423feb9278d82172ff86349b464f7c08f07624574a5cc9152f | Python | 4,420 | 91 | import numpy as np
import pandas as pd
import pytest
from sklearn.gaussian_process.kernels import RBF, DotProduct
from pgmpy.ci_tests import HSIC
@pytest.fixture
def hsic_data():
rng = np.random.default_rng(seed=42)
df_ind = pd.DataFrame(rng.standard_normal((200, 3)), columns=["X", "Y", "Z"])
X = rng.n... |
aba0a8726b9a863e2199acabeee19310f09b87de33553a471d153daf4e935694 | Python | 4,422 | 111 | """Utility functions for experiments."""
import os
import numpy as np
import torch
from typing import Optional
import random
import torch.distributed as dist
from openfold.utils import rigid_utils
Rigid = rigid_utils.Rigid
def get_ddp_info():
local_rank = int(os.environ["LOCAL_RANK"])
rank = dist.get_rank()
... |
9f8ad623b3d6b4aabf1d225c8f4c774f5f019e381484256192dcb139b7ea26cd | Python | 4,426 | 68 | """Impact-style shaded tables: cell background encodes magnitude (LaTeX colortbl), so a reader sees the protocol
gradient and the coverage collapse without reading every number.
tables/table3_shaded.tex : MAPE by protocol x estimator (blue ramp, darker = worse)
tables/table4_shaded.tex : coverage by method x protoc... |
70b0571189d82294dce519611132e84cf5107ff72de6efdb038fd6a02c9cd546 | Python | 4,430 | 120 | import numpy as np
from multiprocessing import cpu_count, Pool
from dipy.core.geometry import cart2sphere
from dipy.core.ndindex import ndindex
from dipy.reconst.shm import sph_harm_lookup
from dipy.reconst.csdeconv import forward_sdt_deconv_mat, odf_deconv
def odf_sh_to_sharp_parallel(odfs_sh, sphere, mask=None, ... |
0b80aa9b3db7475dc8e9077e11fdef5ab92a9d970a4c5bb19645de896186744f | Python | 4,431 | 94 | import pandas as pd
import numpy as np
import argparse
def get_data(type, feature_num_type, path, feature_path, sample):
if type == 'count':
data = pd.read_csv(path + '/RNA_all_TPM.txt', sep='\t')
data = data.rename(columns={data.columns[0]: 'feature'})
data=data.drop_duplicates()
... |
bfe7945afe3e32f2703efc4e5cbd034557aa4bbd79b667e6cde99e51c7849981 | Python | 4,434 | 124 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for d... |
508b039f92808d42a782299d7cd0c720467cd3e93d0189726ec51973d34539b6 | Python | 4,436 | 93 | import argparse
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
import scipy as sp
import scipy.stats
import pyemma
from pyemma.util.contexts import settings
import MDAnalysis as mda
# My own functions
from pensa import *
# -------------#
# --- MAIN --- #
# -------------#
if __name__ =... |
b62eb92123a3ae9cbb0ee1a874dee1b766980a5de05f820357908eecaa9c9178 | Python | 4,436 | 150 | import os
import argparse
import numpy as np
import scipy.ndimage
from skimage.morphology import ball
import img3
import matplotlib.pyplot as plt
parser = argparse.ArgumentParser()
parser.add_argument('-a', type=str, required=True, help="annotated nrrd")
parser.add_argument('-s', type=str, required=True, help="segmen... |
67606bf43ecc56ac435888c2bfbd3e4e522a0ec8c9938da075136eeec72eaa41 | Python | 4,437 | 143 | from functools import partial
from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from langchain_classic.agents.openai_assistant import OpenAIAssistantRunnable
def _create_mock_client(*_: Any, use_async: bool = False, **__: Any) -> Any:
client = AsyncMock() if use_async el... |
97b6ed6e9628611835840514188519e923c15c0582a0cd583f9a34399a7be01b | Python | 4,438 | 120 | """
This script is used to prepare GCT files for the GTEx eQTL pipeline.
Specifically for converting BrainSeq genotypes using TOPMed imputation
as well as the TPM and count files provided by BrainSeq.
This script has been modified from the caudate manuscript for interaction
analysis with sex.
Original Author: Apuã Pa... |
ad86c4a8f85ed2db3f225463904da9b066d620fd3137e24265ddaff4805057cf | Python | 4,438 | 141 | import datetime
import gc
import logging
import os
import hydra
import pytorch_lightning as pl
import torch
import wandb
from omegaconf import DictConfig, OmegaConf
from pytorch_lightning import loggers as pl_loggers
from pytorch_lightning.callbacks import LearningRateMonitor
from src.models.smp.dataset import Histol... |
47a2f946b1e039ff6d247680e2698e609c0046f95be45559163348cd4d6ef1f9 | Python | 4,439 | 108 | import numpy as np
import matplotlib.pyplot as plt
from pensa.dimensionality import \
get_components_pca, \
get_components_tica
from .statistics import \
feature_correlation
def pca_feature_correlation(features, data, pca=None, num=3, threshold=0.1, plot_file=None, add_labels=False):
"""
Calculat... |
f62365c8cf0b75d775e22ba178b4215c0700b4972bf728300ccd783abb35fe6b | Python | 4,439 | 118 | import os
import sys
import random
import datetime
import numpy as np
import argparse
import yaml
import torch
import requests
from tqdm import tqdm
class LoadFromFile(argparse.Action):
# parser.add_argument('--file', type=open, action=LoadFromFile)
def __call__(self, parser, namespace, values, option_stri... |
a38b53c90af3878e627f579378bd094a7555c39bf8cac0fac511bd801cd36425 | Python | 4,444 | 119 | """
Code from this file was mainly taken from tf_explain package,
see https://tf-explain.readthedocs.io/en/latest/methods.html#vanilla-gradients
"""
import tensorflow as tf
from warnings import warn
print("TensorFlow version:", tf.__version__)
# tf.enable_eager_execution()
tf.compat.v1.enable_eager_execution()
tf.e... |
fa93560706e0ad6b14969e23b45b9a7cc57a05c621f54a2f1fd2011ef45540c6 | Python | 4,444 | 149 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for d... |
d5de78534fed7dc0c04e67827d258aa631ecf03b75865acef592fc642e938e18 | Python | 4,445 | 149 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2026 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for detai... |
9917002710464aff8ffd8cf997e36b3412ae510cf0ed8c0da462052e7712bf8f | Python | 4,447 | 121 | import numpy as np
import pandas as pd
import os, tqdm
from scipy.ndimage import map_coordinates
from skimage.io import imread
from scipy.ndimage import label
from skimage import measure, img_as_bool
if __name__ == '__main__':
import sys
sys.path.append(os.path.join('..','..'))
from morgana.ImageTools.morphol... |
6a86bd2901df95bab7a6e0add20870e3b0cee7c25a3d77db4c6ccd0428d04231 | Python | 4,448 | 117 | """
Obtain methylated k-mer frequencies for ILP objective function weighting.
"""
from collections import defaultdict
from itertools import product
import numpy as np
import pandas as pd
import pickle
from utils.constants import KMER_LEN
from utils.constants import METHYL_BED_COLS
from utils.misc import valid_cpg_m... |
f16c1cc22a7e205ea388f7cec18a1dbe1216757eacbf7520092d7781004ee229 | Python | 4,448 | 131 | """Select examples based on length."""
import re
from collections.abc import Callable
from typing import Any
from pydantic import BaseModel, Field, model_validator
from typing_extensions import Self
from langchain_core.example_selectors.base import BaseExampleSelector
from langchain_core.prompts.prompt import Prompt... |
70f4fa6ddc0407d8c7c73bfaf227a12d5fae36b9628b4d79f2ca342457f0b79e | Python | 4,451 | 120 | import torch
def _maybe_num_nodes(index: torch.Tensor, num_nodes=None) -> int:
if num_nodes is not None:
return int(num_nodes)
if index.numel() == 0:
return 0
return int(index.max().item()) + 1
def _scatter(src: torch.Tensor, index: torch.Tensor, dim_size: int, reduce: str) ->... |
286aba41d8994ffa33dddfdf4057f36a2e04087d4b35ea7a5059dc645985a008 | Python | 4,452 | 138 | """
##############################################################################
#
# Merge salmon quantification results tables of distinct samples
#
# AUTHOR: Maciej_Bak
# AFFILIATION: University_of_Basel
# AFFILIATION: Swiss_Institute_of_Bioinformatics
# CONTACT: wsciekly.maciek@gmail.com
# CREATED: 05-... |
8cc34ffecdc55509526629e990306bde97252255f9a23b1ce48cd4310cf68d2d | Python | 4,452 | 124 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2026 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for detai... |
e4c301e5530cb39ff3d19ec799703aa11c6b92523765a8aa2cc06299a15a7df5 | Python | 4,452 | 114 | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 24 15:38:10 2020
@author: gritti
"""
import tqdm, os, glob
from skimage.io import imread
import numpy as np
import time
from morgana.DatasetTools import io as ioDT
from morgana.MLModel import io as ioML
from morgana.MLModel import train
#################################... |
1632d13f2779f72b529d79204efea904ec3fe723a3288b157f0611881b44b2aa | Python | 4,454 | 113 | import os
from morgana.DatasetTools.morphology import overview as overviewDT
if __name__=="__main__":
input_folder = "V:/Lilli_Hahn/data/EH23H_signaling-perturbation/EH24H_DIF01/MOrgAna/images/Control_CHIR/24h"
"""
overviewDT.createCompositeOverview(input_folder)
"""
import numpy as np
import... |
79a94f2f90347538a02b057b1b2a8fb6160c4b8fd2eb9fe41ed333da6fe3ec0c | Python | 4,459 | 112 | # Copyright (c) DP Technology.
# 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
import copy
import pandas as pd
import numpy as np
import torch
from torch.utils.data import DataL... |
843f1409247fae4fd2a91c4cbeaa73412f32dee319856c850b1a176975a6b261 | Python | 4,462 | 149 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for d... |
171a0e87bb1fdb2a738871a079fb8c8531881d9dced1240cc83105b732185678 | Python | 4,463 | 149 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2026 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for detai... |
a35fc86f60e96fbb665384ef03e8bdb35be845bce3c7965e1a09873092eefdbf | Python | 4,464 | 132 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import nibabel as nib
import numpy as np
import os
DESCRIPTION = 'DMRI Data Normalization with B0 image and calculation of Spherical Mean Image. Cornelius Eichner 2020'
FSL_LOCAL = '/data/pt_02101_dMRI/software/fsl6/bin/'
def buildArgsParser():
p... |
7d48920391c856b78851effc25375a2bea749b8db0c742ccf6581e0845613801 | Python | 4,470 | 128 | #!/usr/bin/env python3
from typing import Optional
import pandas as pd
import argparse
import yaml
import pathlib
import matplotlib.pyplot as plt
import upsetplot
def get_upset_data_frame(data, reference, query):
sets = data.groupby(reference)[query].unique().map(set)
all_values = data[query].unique()
re... |
bdee142ba9667d474e515567199a8104c4c18882d74d984d5396e2680306d012 | Python | 4,473 | 125 | """Class for a VectorStore-backed memory object."""
from collections.abc import Sequence
from typing import Any
from langchain_core._api import deprecated
from langchain_core.documents import Document
from langchain_core.vectorstores import VectorStoreRetriever
from pydantic import Field
from langchain_classic.base_... |
beaa551d71a7596973a3966d8b6ae43e7178b4734e9f37cd2b7623862beb9277 | Python | 4,473 | 126 | """DocumentFilter that uses an LLM chain to extract the relevant parts of documents."""
from __future__ import annotations
from collections.abc import Callable, Sequence
from typing import Any, cast
from langchain_core.callbacks import Callbacks
from langchain_core.documents import BaseDocumentCompressor, Document
f... |
fbb8f84e9a98d32fb985105e6e9872ff00aa8e84e05e828cf30ef169dbba05ca | Python | 4,474 | 138 | # /// script
# requires-python = ">=3.12"
# dependencies = ["iohub", "numpy", "tifffile", "zarr"]
# ///
"""Convert a TIFF / .npy / plain-zarr array into a viewable OME-Zarr.
Writes an HCS OME-Zarr (``.../0/0/0``) with a TCZYX array, named channels, and a
pixel-size scale transform, so it can be read by ``wo rec`` and ... |
ebcb5162042e2846df6052c6c461b64bd5ce86a7cf8f1ae5a2024f4d5bfb35ed | Python | 4,476 | 172 | '''
cgat_build_report_page.py - build a report summary across projects
=======================================================================
Purpose
-------
This script scans all of :file:`/ifs/projects/sftp` for
:file:`index.html` files and outputs an html formatted summary table
into :file:`/ifs/projects/overvie... |
0c195be04deef61dcff77db6635a57c1f1f474f49a069fa11489fcabbd882d6b | Python | 4,478 | 131 | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 24 16:26:06 2020
@author: gritti
"""
import os, tqdm
from skimage.io import imread, imsave
import numpy as np
import scipy.ndimage as ndi
import multiprocessing
from itertools import repeat
# import sys
# sys.path.append(os.path.join('..'))
from orgseg.DatasetTools impo... |
0673b9b6747842d8145e927692823aa69891d60e2cf82205586db92b2e02665e | Python | 4,480 | 151 | from __future__ import print_function
import sys, time, datetime, os, contextlib, tempfile, shutil, json, re
from functools import wraps
from svtyper.parsers import SamFragment, Vcf
# ==================================================
# BAM and JSON output
# ==================================================
# writ... |
2de6c7a2c6aa1ec515e4f40320f02b0a87c3cc06fe5361b9b05f952a8492f3ca | Python | 4,485 | 104 | """Content-checked stage reuse and atomic publication of pipeline outputs."""
from contextlib import contextmanager, ExitStack
import fcntl
import json
import os
from pathlib import Path
import tempfile
from threading import Lock
from time import perf_counter
from utils.files import atomic_json, sha256_file
@context... |
066ccf56bc1f095c3588f96dcfce003d73064a6bc529b0ed3dd4d363541e10bb | Python | 4,486 | 120 | import os
import shutil
import mdtraj as md
import tempfile
import numpy as np
import torch
from diffnets.utils import get_fns
from diffnets.data_processing import ProcessTraj, WhitenTraj
CURR_DIR = os.getcwd()
UP_DIR = CURR_DIR[:-len(CURR_DIR.split('/')[-1])]
SCRIPTS_DIR = UP_DIR + 'scripts'
def assert_matrix_is_id... |
9bccdd125a1854627d9ff33c6a6d4743ca22151e077216945ee2836821010aeb | Python | 4,490 | 99 | import logging
import os
import socket
import sys
import numpy as np
import pandas as pd
from configs.configs import get_config_dict
from helpers.hcp import get_human_connectome_project_subjects, get_human_connectome_project_subjects_phenotypes
from helpers.morphometricity import variance_component_model, get_phenoty... |
fb0a0dc3a08285856892df3f69f7f8aa26bdcf81d5d00e45e03cb92c0c82956b | Python | 4,491 | 137 | import numpy as numx
import pydeep.misc.io as IO
import pydeep.misc.visualization as STATISTICS
import pydeep.misc.visualization as VISUALIZATION
import pydeep.rbm.estimator as ESTIMATOR
import pydeep.rbm.model as MODEL
import pydeep.rbm.trainer as TRAINER
# Model Parameters
h1 = 20
h2 = 20
v1 = 10
v2 = 10
v1_org = 1... |
a0fb871b1b10205e51f5e4c04a9b379e4d1b3a511f9d6f05e78e52ab49a9426b | Python | 4,493 | 104 | import numpy as np
from tensorflow import keras
import json
def load_labels():
CLASS_INDEX_PATH = ('https://storage.googleapis.com/download.tensorflow.org/data/imagenet_class_index.json')
fpath = keras.utils.get_file(
'imagenet_class_index.json',
CLASS_INDEX_PATH,
cache_subdir='models'... |
22ef894c29d5650f9653dfa318e87cd10f95e69d491fd9f15ddece2933f09568 | Python | 4,495 | 80 | import argparse
import yaml
from mimic3benchmark.mimic3csv import *
from mimic3benchmark.preprocessing import add_hcup_ccs_2015_groups, make_phenotype_label_matrix
from mimic3benchmark.util import dataframe_from_csv
parser = argparse.ArgumentParser(description='Extract per-subject data from MIMIC-III CSV files.')
par... |
6362af8d68a9ca35b0d5b7e5f056e2adcb920f859ecc85fe4d8451b68e8811e2 | Python | 4,499 | 135 | import pandas as pd
import torch
import numpy as np
import os
import matplotlib.pyplot as plt
from src.data import get_sim_data
os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'
model = torch.load(os.path.join("../model", f"model_sim"))
x_seqs, x_statics, y, _, seq_features, static_features = get_sim_data('Label', 'Simulati... |
f9e48c30ca2c6a86a0da11577ba6ff566165eb6617c080aa55cc80b2dc237242 | Python | 4,500 | 142 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from keras import backend as K
from keras.engine import InputSpec
from keras.engine.topology import Layer
import tensorflow as tf
class DynamicPaddingLayer(Layer):
'''Adds padding to input tensor such th... |
9102a1f65e85451c209bc075b06d1d251719ab4ff7f9978991a0faf8f1bd72ed | Python | 4,501 | 120 | import pytest
import os
def test_PointMutationExecutor():
"""
Check that a PointMutationExecutor can be instantiated properly for ALA->ASP dipeptide in solvent and that a
HybridTopologyFactory object can be generated.
Also check that counterions are added.
"""
from pkg_resources import resourc... |
eab4b1ec0e7690e20e90a05837eacc71232381313d7d3c52dcb90ba6fdc14ba9 | Python | 4,505 | 148 | #!/usr/bin/env python3
# pylint: disable=line-too-long
"""
Various functions that apply extra annotation filters to the annotation process
"""
import logging
from itertools import product, chain
from enrichm.toolbox import window, cluster
class ClassifyChecks:
'''
Applies extra, manually defined filters to the... |
3697b8b432b2ade9d71ca4f95bba7456a872d4a753e6f0d167535b124c859fde | Python | 4,507 | 122 | import argparse
import os
import pathlib
from tkinter import BOTTOM
import urllib.request
import numpy as np
import pandas as pd
from joblib import Parallel, delayed
import mne
from mne.io.brainvision.brainvision import _aux_vhdr_info
from mne_bids import write_raw_bids, print_dir_tree, make_report, BIDSPath
lemon_in... |
ca308e7f3b51cd71ddcb4c611aea1a0a566c3f536694b5ecfe142e24aff959d1 | Python | 4,508 | 142 | import torch
import torch.nn as nn
import torch.nn.parallel
import torch.utils.data
from torch.autograd import Variable
import numpy as np
import torch.nn.functional as F
class STN3d(nn.Module):
def __init__(self, channel):
super(STN3d, self).__init__()
self.conv1 = torch.nn.Conv1d(channel, 64, 1)... |
4857b8217bbdce26a7326da347c92475d9a8d449cff4b26b3a4bf0ad2f6921ec | Python | 4,509 | 123 | # Copyright 2022 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed... |
d2617c4441a0b52b879d51a78cbac964393ca76204b3b0005205eb87922ccc77 | Python | 4,510 | 83 | """Selection-bias-free ('honest') gene-chord AUC, answering the reviewer's double-dipping objection.
The original number selected the top-K attributed genes on the FULL data, then cross-validated a logistic
on those genes -> feature selection outside the CV loop -> optimistic. Here, for each seed we split
train/test, ... |
614b2b82126b995a44e15f93e72a100c08829acd2f0ab584a03d7aa1d6aac71e | Python | 4,511 | 150 | import glob
import os
import SimpleITK as sitk
import numpy as np
from medpy.metric import binary
from sklearn.neighbors import KDTree
from scipy import ndimage
import argparse
def read_nii(path):
itk_img=sitk.ReadImage(path)
spacing=np.array(itk_img.GetSpacing())
return sitk.GetArrayFromImage(itk_img),sp... |
7b0a45cdf43b9f77575ffb2cdf9af01422c46e6524527d477a1eb5a82419ee22 | Python | 4,512 | 119 | from collections.abc import Hashable
from math import lgamma, log
import numpy as np
from scipy.special import gammaln
from pgmpy.structure_score.bdeu import BDeu
from pgmpy.utils import get_state_counts_array
class BDs(BDeu):
r"""
BDs structure score for discrete Bayesian networks.
BDs is a sparse-dat... |
b35ec506eb670ab76838816eb856a8b082f04c3671cd88dcf1fb86be131b4c3e | Python | 4,512 | 141 | import os
import sys
import re
import types
import itertools
import glob
import pandas
import pandas.rpy.common
from cgatReport.Tracker import *
from cgatReport.Utils import PARAMS as P
from collections import OrderedDict as odict
##########################################################################
############... |
db06c6c48eded3a76e01e381449c5af54549b1445a124071ce013266b958c791 | Python | 4,514 | 94 | from edNEGmodel.edNEGmodel import *
from functions.initial_values import *
from functions.solve_edNEGmodel import *
'''
Physiological conditions
'''
I_stim = 8e-5 # [uA]
alpha = 2
t_dur = 6e3 # [ms]
t_span = (0, t_dur)
stim_start = 0.2e3
stim_end = 5.5e3
# Save path
# checking if the directory exist and create... |
ef21564294bb7dfb7d93f9763ec7b519d3b4cb05b054a8ebd9f72d8655b69d95 | Python | 4,515 | 120 | # Copyright (c) 2019, Adobe Inc. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike
# 4.0 International Public License. To view a copy of this license, visit
# https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.
import torch
import torch.nn.parallel
... |
48d41cc0e50bd25d5b35784ce84f6726845cc5a751b26d9e758fff02cadd82a2 | Python | 4,517 | 119 | import pytest
from langchain_core.caches import RETURN_VAL_TYPE, InMemoryCache
from langchain_core.outputs import Generation
@pytest.fixture
def cache() -> InMemoryCache:
"""Fixture to provide an instance of InMemoryCache."""
return InMemoryCache()
def cache_item(item_id: int) -> tuple[str, str, RETURN_VAL... |
1971bef4e89c7078db88b17be699ba1e8241d25080e45891d61057c3d1720cf7 | Python | 4,519 | 99 | """upsamples the shipped template meshes (src/craniumpy_core/templates/) to
~25,000 vertices each, saved alongside the originals as new "_25k" files -
a one-time script, not run at app startup (same pattern as
generate_demo_cohort.py). none of the originals are touched, and nothing
elsewhere in the app switches to usin... |
74fbb4174933c62bb552d13f792367ebf15fb621b919871210600e9be21ab6b2 | Python | 4,519 | 99 | """Phase 2b: proper effectorness control for the mouse ribosomal signal, using
scanpy diffusion pseudotime (DPT) instead of the marker-based proxy from the
linear preview. Residualises the ribosomal-only naive-vs-TEM separation against
sequencing depth, cell cycle, and the DPT effectorness axis, and reports whether
the... |
95bac50a99256f1df7788caca2c4e40ecbab3f4c3b37ac56f1a5596ffe73d141 | Python | 4,519 | 120 | import os
import sys
import re
import types
import itertools
import glob
import pipelineTracks
from cgatReport.Tracker import *
from cgatReport.odict import OrderedDict as odict
from cgatReport.Utils import PARAMS as P
EXPORTDIR = P['cpg_exportdir']
DATADIR = P['cpg_datadir']
DATABASE = P['cpg_backend']
UCSC_GENOME =... |
60f8dc529bfc9fb13c3cf6e484c3822efcd260399f638e63b5da97cfdfbb9143 | Python | 4,520 | 122 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 4 16:18:49 2021
@author: athanasiadis
"""
"""
significance
______________________
This is a script that runs a permutation test on a given dataset.
Input:
- several functions needed for the permutation test.
Output:
... |
fcc69905baea771c56b76f0a405285e89d4e7672d29a5cdbefadcbede055c815 | Python | 4,521 | 162 | from pathlib import Path
from typing import Any, Union
import numpy as np
import cv2
from PIL import Image, ImageEnhance
def load_image(file_name, path_to_images=None, rgb: bool = True):
path = (
file_name
if isinstance(file_name, Path) is True
else path_to_images.joinpath(file_name)
... |
eb1ce58d6d3d24f2cd234c1a0177567df31d41faf803f0796422ccc363a08f42 | Python | 4,524 | 116 | import torch
import copy
from .radial_function import RadialFunction
from .utils import reduce_edge
class EdgeDegreeEmbedding(torch.nn.Module):
"""
Args:
num_channels (int): Number of spherical channels
lmax (int): Maximum degree (l)
... |
819a9aab1a074e99bdcc4573686534d245cd7f2a847ab3aa8993d871ebf36eb0 | Python | 4,525 | 86 | #!/usr/bin/env python
import gzip
import sys
import os
import unittest
import hashlib
import tempfile
from ldr.annotations.annotationsbed import AnnotationsBed
from ldr.annotations.annotations import Annotations
from ldr.annotations.intersectedbed import IntersectedBED
from ldr.annotations.binary import BinaryAnnotat... |
c8f6bc331f34db52aae22777ee499016a2732b5163803d200aedc6cb60332815 | Python | 4,525 | 106 | import itertools
import numpy as np
import random
from scipy import stats
from src.PID import compute_store, format_data
def get_korder_tuples(num_sources, args):
# returns all k-order tuples
indices = range(0, num_sources)
korder_tuples = itertools.combinations(indices, args.k_order)
korder_tuples =... |
59d9468c4d6e573cff80e81ba3aea68312acf035a6ed75f058043ffa24c66238 | Python | 4,526 | 79 | """Ablations with the GBDT backbone (3 seeds):
A1 anchoring reference length K0 in {0 (no anchoring), 3, 5, 10, 20} under P3 and P4
A2 number of source datasets under P4 (train on 1, 2 or 3 of the other datasets; all subsets)
A3 training-cell learning curve under P4 (fraction of source cells 10/25/50/100%)
A4 ... |
ae1f02c86f5c5ce1f70a743b982e2f3f55c4b8f23445f854aeda2c04791acb17 | Python | 4,526 | 147 | import torch
import torch.nn as nn
from e3nn.util.jit import compile_mode
from torch_scatter import scatter
import hienet._keys as KEY
from hienet._const import AtomGraphDataType
@compile_mode('script')
class ForceOutputFromEdge(nn.Module):
"""
works when edge_vec.requires_grad_ is True
"""
def __in... |
f458f9516e3b302f17505f4717a6df022cc79f43377d8a0081e36935ff5e4b15 | Python | 4,527 | 92 | # Sconda conda activate abc; cd /mnt/BioAdHoc/Groups/RaoLab/Edahi/Projects/09.TimeCourse5hmC/ForFerhatGit/FCDNN/results/cross_validation_allsamples/model_per_chr/; python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
import os
import json
# Load the CSV file into a DataFr... |
fa620dba9c71bb16fd8caa049d6b9dfef8aa3b40252fdbb906f24df6ad1dfdb7 | Python | 4,527 | 161 | """**Prompt values** for language model prompts.
Prompt values are used to represent different pieces of prompts. They can be used to
represent text, images, or chat message pieces.
"""
from __future__ import annotations
from abc import ABC, abstractmethod
from collections.abc import Sequence
from typing import Any,... |
d21f2fc3b78d564fdc8e1a263e5878f41fb4ea01e92fabaeb0f2dc769538c42a | Python | 4,529 | 125 | # https://github.com/Po-Hsun-Su/pytorch-ssim/blob/master/pytorch_ssim/__init__.py
import torch
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
from math import exp
def gaussian(window_size, sigma):
gauss = torch.Tensor([exp(-(x - window_size//2)**2/float(2*sigma**2)) for x in... |
cfdb3e0017465c24b17a0b5b7d7b1308d1a3d945339fbf3bfb8f579f78b1c689 | Python | 4,531 | 152 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for d... |
1f3444ddc6264ad9db77f2a4d20e819b9d8fe4368ef811ba6ab602ba50fd6b7e | Python | 4,532 | 110 | """On-the-fly SAD density superposition + ridge projection to ``sad_coeffs``."""
from __future__ import annotations
import math
from dataclasses import dataclass
from typing import Any, Dict, Optional
import torch
from scdp.data.gt_coeff_projection import make_gto_basis_pack
from scdp.data.sad_density import Atomic... |
d29ca4463659ecdc5948dd8ef41dffed852f7faa9c1dd4ce4e9f5daf01ef3c51 | Python | 4,532 | 152 | ####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2026 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for detai... |
1359ff88c25026e5743ca90bb6a6a068a826797414b3474da7812cce741b1881 | Python | 4,533 | 143 | import logging
from collections import Counter
import numpy as np
import torch
from torch.utils.data import Sampler
logger = logging.getLogger(__name__)
class RepeatsBatchSampler(Sampler):
def __init__(self, keys, subset_index=None):
"""
Batch sampler where each batch consists of all samples wit... |
93e7cdc29cfaeb5cd8649eafc356b96039567d4be287446f1d885e73b7d4a5fa | Python | 4,533 | 115 | import logging
import os
import socket
from fcest.helpers.inference import run_adam_vwp, run_adam_svwp
from fcest.models.wishart_process import VariationalWishartProcess, SparseVariationalWishartProcess
import gpflow
from gpflow.ci_utils import ci_niter
from gpflow.utilities import print_summary, set_trainable
import ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.