sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
d9ded9cf5ed7e3a45224652196f3e4df046148c16c5eb1f84d7254c44cfbb983 | Jupyter | 2,141 | 80 | # %% [markdown]
# # Import modules
# %%
import PFN_model
from PFN_model import PFN, BuildSSInitial
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# %% [markdown]
# # Load stimulus file created from MPC (e.g. '**stims.csv')
# %%
stimuli = pd.read_csv('model-stims_bio-validation_varying-contro... |
0d24f067c490352fbbf5f26f2eede633d03789c4ab137125b129ad2cad314fc9 | Jupyter | 2,143 | 68 | # %% [markdown]
# # Plot tractometry results
#
# You have to install seaborn 0.9 and run the following script.
# %%
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from tractseg.libs import exp_utils
values = {}
#Load tractometry results subject 1
values["s0"] = np.loadt... |
86edf6fe2e841be8a1bbf4d7670cc9bced491b8c7798a297d5ec53ad2118826a | Jupyter | 2,167 | 119 | # %% [markdown]
# # Figure S5
# %%
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import sys
import os
# Get the absolute path to the project root (one directory up from notebooks/)
root_path = os.path.abspath("..")
sys.path.append(root_path)
os.environ["JAX_PLATFORMS"] = "cpu"
from src im... |
83b1457fdbce416bc0c2e61461ce7cac5b70219140d8b19c02a189b7a3180bd8 | Jupyter | 2,177 | 79 | # %% [markdown]
# # Query BIDS dataset and extract full paths to data files
#
# This script uses BIDSLayout to query BIDS dataset and extract:
# - anatomical images: `anat_files`
# - brain masks: `mask_files`
# - confounds: `conf_files`
# - functional images: `fmri_files`
#
# All paths are stored as JSON file. Anato... |
d4da5a608314a7cb94f365380cbb5198d1c7b1d2faddae3ab87b099274a7b396 | Jupyter | 2,196 | 119 | # %%
import sys
import os
from os.path import dirname, realpath, join
base_dir = dirname(dirname(os.getcwd()))
import pandas as pd
from os.path import join
# %%
base_dir
# %% [markdown]
# ## SUC Fusions
# %%
sys.path.insert(0, base_dir)
from config_path import PROSTATE_DATA_PATH, PLOTS_PATH
# %%
# fusions_file = j... |
0223473dcacba23031ab50214a4983cc5f1a9cb359a375710d89819712b2b777 | Jupyter | 2,224 | 110 | # %% [markdown]
# # NPY format
# %% [markdown]
# Some links:
# %% [markdown]
# * [NPY Spec](http://docs.scipy.org/doc/numpy-dev/neps/npy-format.html)
# * [C++ library](https://github.com/rogersce/cnpy)
# %% [markdown]
# ## Scope
#
# The initial MATLAB implementation could have the following limitations:
#
# * **Su... |
184315aead06fee83c973d3f10ae489e3a5d9c31448c91d1eaeb092203e8606d | Jupyter | 2,226 | 58 | # %%
import os,sys
sys.path.append(os.path.realpath(os.path.join(os.getcwd(), '..')))
import warnings
warnings.filterwarnings("ignore")
# %%
import scanpy as sc
import pandas as pd
import CPS
# %%
opt = CPS.config()
args = opt.parse_args(['--seed', '2026'])
args.prep_scale = False
args.sigma=0.8
args.dataset_path = '... |
e2fe609f8c9720296c59136d4bfc13f31296de318714ce1fa92914a692c21454 | Jupyter | 2,232 | 74 | # %% [markdown]
# # Components variance
# %%
% matplotlib inline
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rcParams['svg.fonttype'] = 'none'
emb = np.load('gradient_data/embedded/embedding_dense_res.npy')
# %%
lam = np.squeeze(np.array(list(emb.item()['orig_lambdas'].flatten())... |
81c29ca51eae1e45dcef60ec852d4a26927abb69a7fdac2469dfdaf0295318d5 | Jupyter | 2,235 | 97 | # %% [markdown]
# # Preparation
# %% [markdown]
# ## Loading Python packages
# %%
import polars as pl
import polars.selectors as cs
from src.single_cell import SingleCell
import seaborn as sns
import matplotlib.pyplot as plt
# %% [markdown]
# ## Loading data
# %%
lr_bulk = SingleCell("results/long_read/pbid_filtere... |
83296fe1c32b40b2a59245adc8eee0c2f999f23117c30da00e32c4fd36014c73 | Jupyter | 2,250 | 78 | # %%
library(SPOTlight)
library(Seurat)
library(ggplot2)
library(SingleCellExperiment)
library(scater)
library(scran)
library(dplyr)
# %%
T_names = c( "T993")
for (profile in T_names){
sc_data = readRDS("/data/snRNA_downsample.rds") #######
st_data = readRDS(paste0("/data/",profile,"cellbin.rds"))
sce <- a... |
a1db65bf312c13ebf3bb2cc9c7b78712fa4db896191055a1f9b8414ec72e2493 | Jupyter | 2,258 | 76 | # %% [markdown]
# # Human connectivity embedding
# %%
# Load affinitity matrix
aff = np.load('gradient_data/conn_matrices/cosine_affinity.npy')
# %%
import sys
sys.path.append("../topography/utils_py/mapalign")
from mapalign import embed
emb, res = embed.compute_diffusion_map(aff, alpha = 0.5)
# %%
# Save results
n... |
d7a46577c1acffbe3d7508ab3e1377ebc25c28e15b54ab41d6a92f51edc0d636 | Jupyter | 2,262 | 53 | # %%
import numpy as np
import os
import pandas as pd
from collections import defaultdict
# %%
res_dir1 = "/mnt/c/Users/Алексей/OneDrive/projects/uio/cmma/tests/experiment_8"
res_dir2 = "/mnt/c/Users/Алексей/OneDrive/projects/uio/cmma/tests/experiment_9"
res_dir3 = "/mnt/c/Users/Алексей/OneDrive/projects/uio/cmma/test... |
81e07647006f6a60fcd821d6ba434b1202428853e4aeb0ae25951f45cf65b4e5 | Jupyter | 2,318 | 92 | # %% [markdown]
# ## Statistical Analysis
#
# We provide a module (`paper_ANOVA.py`) with functions used here for fitting ANOVA and ANCOVA's to data, with additional bootstrapped confidence intervals and partial eta squared $(\eta^2_p)$ effect sizes for main effects.
#
# The provided module requires :
#
# - num... |
9cc998a685c16c7f544cddd42a7e390db0e6aa4ae02d81d2f92fb1bb4f6fa940 | Jupyter | 2,331 | 82 | # %%
import warnings
warnings.filterwarnings('ignore')
import pandas as pd
import numpy as np
from CleanData import *
from MergeData import *
from AugmentData import *
from CorrectHeading import *
from PlotData import *
# %%
# import pre-cleaned data
trajec_df = pd.read_hdf("../ExperimentalData/60cms/flight_trajector... |
77e999312aa6b52abdbac8b438bcab03bf5410e0948812df61ede4f8e1c5be87 | Jupyter | 2,345 | 112 | # %% [markdown]
# # Load & Parse Data
# %%
import importlib
import utils.parse_data
importlib.reload(utils.parse_data)
# %%
from utils.parse_data import parse_dataset
from pathlib import Path
data_path = Path('../data/pooled_stratified_share_vc')
X_train, Y_train, X_test, Y_test, device = parse_dataset(root_dir=d... |
b0f67143ec99b294a7b6c21cd9c17e54458e8c14f1c15511a937b2c330db0a80 | Jupyter | 2,363 | 102 | # %%
# IO packages
from aicsimageio import AICSImage
import os
import imageio
# calculation packages
import numpy as np
# segmentation packages
# update these packages from the playground file's first cell
# %%
def segment_structure(image_name, filepath, output_path):
""" Takes a filepath that is a single chan... |
8e8ead818b92e24d29d49085a59f99738a473033297a6f0cef6fcbb24f312a7e | Jupyter | 2,379 | 68 | # %% [markdown]
# # DLC total video time
#
# Total duration of labelled close-up video analysed.
# %%
import os
from datetime import datetime
import cv2
from cichlid_omr.config import data_dir, load_config, output_dir
cfg = load_config()
# %%
video_base_folder = str(data_dir() / "close-up" / "DLC-analyses")
video_... |
3313d55fa49c3b6ce7edf6e6a337a59218684c4e5ab2244ee56b27c00d3ea494 | Jupyter | 2,400 | 125 | # %%
import sys
import os
from os.path import dirname, realpath, join
base_dir = dirname(dirname(os.getcwd()))
import pandas as pd
from os.path import join
# %%
base_dir
# %% [markdown]
# ## SUC Fusions
# %%
sys.path.insert(0, base_dir)
from config_path import PROSTATE_DATA_PATH, PLOTS_PATH
# %%
fusions_file = joi... |
d54ac5cd3e35994156cab6aaedc186136d3e515801c9cd5cd3cc65c0252af549 | Jupyter | 2,411 | 55 | # %%
library(dplyr)
library(Matrix)
library(data.table)
library(Seurat)
library(ggplot2)
library(RColorBrewer)
cols = c(brewer.pal(9, "Set1"),brewer.pal(8,"Set2")[1:8],brewer.pal(12,"Paired")[1:12],brewer.pal(8,"Dark2")[1:8],brewer.pal(8,"Accent"),brewer.pal(12, "Set3"),brewer.pal(9,"Pastel1"),brewer.pal(8,"Pastel2"))
... |
c1a0f3c55cc5c3e75888ccba1a0c5531e3ccdcde91857787d5dbb3cb4e1fd394 | Jupyter | 2,425 | 100 | # %% [markdown]
# # Individual fish example plots
#
# Generate individual-fish example plots from `raw_data.json`.
# %%
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import os
from scipy import stats
from cichlid_omr.config import data_dir, load_config, output_dir
from cichlid_omr.figures imp... |
bf303c6da6bc2de950fd047085f91d26a5a56a1f0999ec14957cf489ae88d55f | Jupyter | 2,434 | 75 | # %% [markdown]
# # Embeddings
# %% [markdown]
# Prerequisites
#
# 1. Tokenize and preprocess the RELISH and TREC data sets.
# - Use the medline-preprocessing module to retrieve both the RELISH and TREC data sets.
# - Make sure to tokenize and preprocess it and save both data sets as .npy files.
# %%
import ... |
5327004ac40920051c95570a652eac50dc85e357841c8f55d60aceed6803b8c9 | Jupyter | 2,467 | 79 | # %% [markdown]
# # bombcell: Methods Text Generation
#
# This notebook demonstrates how to automatically generate a methods section paragraph, based on the parameters you used to run bombcell.
# %% [markdown]
# ## 1. Setup
# %%
%load_ext autoreload
%autoreload 2
import bombcell as bc
from pathlib import Path
# %%... |
e37adc5be3956bb8737907b6cbcafc2d74a16b569f7f15ed0537f7b8efbcc3e7 | Jupyter | 2,467 | 80 | # %%
from src.utils import read_fasta
import orfipy
import seaborn as sns
import matplotlib.pyplot as plt
import polars as pl
# %%
full_tx = read_fasta("nextflow_results/V47/final_transcripts.fasta").rename({"seq": "full_tx_seq"})
orfanage_pep = read_fasta("nextflow_results/V47/orfanage_peptide.fasta").rename({"seq": ... |
a329a5e6e0e76a4e76bc20052de69b7b2fc301ebfe5e9d1bf28de940909fc147 | Jupyter | 2,486 | 70 | # %% [markdown]
# # TREC-simplified Relevance Matrix
# %%
import itertools
import pandas as pd
os.chdir('../Playground/relevance_matrix')
from trec_matrix_simplified import load_TREC_data, get_unique_topics, determine_group, prepare_data, save_file
# %% [markdown]
# This code serves two purposes:
# 1. Create the TREC... |
d0923997095e8ddba8c69e3642b1a1dc5ed70f1a265167a0d079b3d8d3caa1f9 | Jupyter | 2,498 | 81 | # %%
import numpy as np
import joblib
from sklearn.metrics.pairwise import cosine_similarity
from visualizations import get_colors, show_factorization_on_image
from PIL import Image
import matplotlib.pyplot as plt
import cv2
region = 1
W, H = np.load(f"{region}_w.npy"), np.load(f"{region}_h.npy")
model = joblib.load(... |
1d6a21e3dd1ab37bc82f98793e2a0770aecc93ce7be96b59e30167d94983828c | Jupyter | 2,511 | 90 | # %% [markdown]
# ### Generating Neuropil Layer Surface Meshes
#
# Once dendrites are succesfully extracted with the needed metadata saved (Neuron Type and Hemisphere), they can be used to reconstruct surfaces meshes for the left and right Lobula layer 1 and Medulla layer 10 using `NeuRosetta`.
# %%
import NeuRosetta... |
2bc8b54159b3359c195e5b5ab774d8e8c3db118d6dd95181c1facd80e287ae34 | Jupyter | 2,518 | 102 | # %%
import json
import pandas as pd
import numpy as np
from os.path import join
from dn_utils.path import path
# %%
from dn_utils.plotting import plot_matrix
%matplotlib inline
# %%
atlas = "combined_roi_4and5"
gamma = 2
# %%
# Create additional paths
gamma_str = str(float(gamma)).replace('.', '_')
path_corrmats = ... |
4063c469d8eaef2982b5ae66c2eb9a704fbe2139cf4aae72e0fb94e0b04f5945 | Jupyter | 2,520 | 90 | # %%
import pandas as pd
import os
# %%
input_dir = "."
output_dir = "./3K_New_Analysis"
# %%
columns_to_copy = [
"Number of all Red Total LDS in inclusion",
"Number of all Red Total LDS not in inclusion",
"Number of Red-only Total LDS in inclusion",
"Number of Red-only Total LDS not in inclusion",
]... |
85212e1bd7abe4895204eb5f10ea3f3cd14db303d6391bf34a565cf6acd15cad | Jupyter | 2,529 | 54 | # %%
library(Seurat)
library(tidyr)
library(ggplot2)
library(patchwork)
library(dplyr)
library(cowplot)
library(RColorBrewer)
best_color <- c("#7974da", "#90d42d", "#ff8b7b", "#61a946", "#02bdfe", "#0068af", "#fd7c01","#E31A1C", "#FDBF6F", "#FF7F00", "#CAB2D6", "#6A3D9A", "#B15928","#FBB4AE", "#B3CDE3", "#BC80BD", "#C... |
4ad5447ce0b72fea2532bb05ede97d17ffdca618220f2fa0bf5b85d9bcd8c0f1 | Jupyter | 2,561 | 104 | # %%
from rdflib import Graph, RDF
from rdflib.namespace import OWL, XSD, SKOS, RDFS
import pandas as pd
# %%
graph = Graph()
graph.parse('../data/input/AI-RHEUM.ttl', format='ttl')
# %%
print(f"Graph g has {len(graph)} statements.")
# %%
import itertools
class Indexer(object):
def __init__(self,it):
se... |
84d5d530419150125baf26060bd4a2c8eb8855bad72336836b1ba7ba459e2826 | Jupyter | 2,562 | 99 | # %% [markdown]
# # Import modules
# %%
import PFN_model
from PFN_model import PFN, BuildSSInitial
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# %% [markdown]
# # Load stimulus file created from MPC (e.g. '**stims.csv')
# %%
stimuli = pd.read_csv('model-stims_bio-validation_varying-contro... |
5fb7280e77e66da324ed6123917473afa6a5a652d89654ed8ed5777f82cfd115 | Jupyter | 2,566 | 84 | # %%
import sys
import os
from os.path import dirname, realpath, join
base_dir = dirname(dirname(os.getcwd()))
base_dir
import pandas as pd
from os.path import join
# %%
sys.path.insert(0, base_dir)
from config_path import PROSTATE_DATA_PATH, PLOTS_PATH, PROSTATE_LOG_PATH
# %%
#https://stackoverflow.com/questions/56... |
2d85afffc4124902512e088302aa86b67e3e8b83c800c36035f60dd2b00a746e | Jupyter | 2,596 | 84 | # %%
import sys
import scanpy as sc
import anndata
import pandas as pd
import numpy as np
import os
import gc
import matplotlib as mpl
from matplotlib import rcParams
import matplotlib.pyplot as plt
import seaborn as sns
import scipy.sparse as sparse
from scvi.data import synthetic_iid
from scvi.dataloaders import AnnD... |
56a534de835fd41647d1386e87921b3ee1258f67d068129bbd1fb8c6f5685e4a | Jupyter | 2,603 | 58 | # %% [markdown]
# Prerequisites
# 1. Tokenize and preprocess the RELISH and TREC data sets.
# - Use the [medline-preprocessing](https://github.com/zbmed-semtec/medline-preprocessing) module to retrieve both the RELISH and TREC data sets.
# - Make sure to tokenize and preprocess it and save both data sets as .np... |
2db4844881235509373d068b81bca96b3a8e230cd5b228f90d964f2ae5701b85 | Jupyter | 2,615 | 77 | # %%
import transformers
import torch
import numpy as np
import os
import csv
from transformers import BertModel, BertTokenizer
curr_dir = os.getcwd()
cache_dir = curr_dir + '/Transformers'
#To check where the model is saved: cd ~/.cache/huggingface/hub
# %%
tokenizer = BertTokenizer.from_pretrained("tbs17/MathBERT",... |
96a711d861e325ec92fd02917b81579ee4efaad14c315552537698ddf48c74fc | Jupyter | 2,616 | 87 | # %% [markdown]
# # Learning Tree Structure from Data using the Chow-Liu Algorithm
# %% [markdown]
# In this notebook, we show an example for learning the structure of a Bayesian Network using the Chow-Liu algorithm. We will first build a model to generate some data and then attempt to learn the model's graph struct... |
b3092663a34270efaad489b08ba92c27b5c216430ca2e96893b52974ab73e090 | Jupyter | 2,630 | 85 | # %% [markdown]
# # GENIE3
# %%
from scprint import scPrint
from scdataloader import Preprocessor
from bengrn import BenGRN, get_perturb_gt
from bengrn.base import train_classifier
from bengrn import compute_genie3
from grnndata import utils as grnutils
from anndata.utils import make_index_unique
import pandas as p... |
0f573dd324fdcee1d911e361fd49b1d25626448c39c080231a6fb79a9a7f22d0 | Jupyter | 2,651 | 166 | # %%
import sys
import os
from os.path import dirname, realpath, join
base_dir = dirname(dirname(os.getcwd()))
import pandas as pd
from os.path import join
sys.path.insert(0, base_dir)
from config_path import PROSTATE_DATA_PATH, PLOTS_PATH, DATA_PATH
# %%
filename = join(PROSTATE_DATA_PATH,'processed/outputs_su2c_tcg... |
0a889a6021b3b70c3af6940156506a6895cde0028a155648661090f6aacba26d | Jupyter | 2,676 | 101 | # %%
# IO packages
from aicsimageio import AICSImage
import os
import imageio
# calculation packages
import numpy as np
# segmentation packages
from aicssegmentation.core.pre_processing_utils import intensity_normalization, image_smoothing_gaussian_slice_by_slice
from aicssegmentation.core.seg_dot import dot_3d_wrapp... |
223afa789bb51d67548a9971067ca169872b4dcbd4e68aae67312373abfdcf60 | Jupyter | 2,701 | 122 | # %%
import os
import pandas as pd
import numpy as np
import openai
import requests
import pandas as pd
import openai
import json
import logging
import time
from typing import List, Dict, Any, Optional
from enum import Enum
from dataclasses import dataclass
import openrouter
# %%
# Import the openrouter module
#... |
f68cf193b6da4cfd366078fc1ac5f881575fca7129850f7ae4e6cd3d75c604e3 | Jupyter | 2,707 | 107 | # %% [markdown]
# ## zeroshot integration
# %% [markdown]
# #### Here we use the lung dataset (https://figshare.com/ndownloader/files/24539942) in SCIB (doi.org/10.1038/s41592-021-01336-8)
# %%
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0,1,2,3" ## set your available devices, each use ~2G GPU-MEMORY
import scanp... |
1b3e51cce104e1fcc1ac9ec39528f480061b97055235302677f81d4f56f26c33 | Jupyter | 2,712 | 59 | # %% [markdown]
# In case of reduction to compute the documents' WMD scores, we need to input pre-annotated documents'tokens to the code generate_wmd_similarity_with_reduction.py.
#
# By doing this we restrict the documents' words to be either MeSH terms or non-MeSH terms, hence not both.
#
# However, the prefix is u... |
646464096d4eb4719b8adab74d3783ceb5176dbae113225162ac02f553ddccfe | Jupyter | 2,712 | 103 | # %% [markdown]
# # Load packages
# %%
import re
import os
import sys
import gzip
import torch
import numpy as np
import pandas as pd
import scanpy as sc
from tqdm import tqdm
from torch.utils.data import DataLoader, Dataset
from transformers import PreTrainedTokenizerFast, GPT2LMHeadModel, GPT2Model
# %% [markdown]
... |
3807a21ab2fff4732f0bfeb262ab115d95341a5a9a50c10744bce08033d0bb5e | Jupyter | 2,757 | 112 | # %%
import json
from os.path import join
import numpy as np
import pandas as pd
from dn_utils.path import path
from pathlib import Path
import matplotlib.pyplot as plt
from bct.algorithms.clustering import agreement, consensus_und
%matplotlib inline
# %%
atlas = "combined_roi_4and5"
gamma_range = np.arange(0.5, 2... |
197b976d097ea83dca2dce829247fed43ba40e03023b5893fc5711c22421d6d3 | Jupyter | 2,761 | 86 | # %% [markdown]
# ### Edged data for dendrites
#
# Create a dataframe of edge level value metrics for each dendrite and save as pickle
# %%
import NeuRosetta as nr
import pandas as pd
import numpy as np
from NeuRosetta.utils.geometry_utils import euclidean_distance
from NeuRosetta.utils.geometry_utils.scaling impo... |
611d9ada120a3c2877bf8c8ac035f0f708b55b9484c77bd6f184e5907c328e19 | Jupyter | 2,763 | 91 | # %% [markdown]
# %%
import pandas as pd
import numpy as np
from tqdm import tqdm
import navis
from fafbseg import flywire as fwy
from fafbseg.flywire import NeuronCriteria as NC
# %% [markdown]
# ### Fetch T4/T5 dataframes (for ID lookup)
# %%
n_types = ["T4a","T4b","T4c","T4d","T5a","T5b","T5c","T5d"]
female_... |
3bfea6c7cb69af04f9751b1203e808a8abe905f631fa288eda3a399503f2ec6f | Jupyter | 2,776 | 110 | # %% [markdown]
# ## Inputs
# ---
# %%
# reading data and working with arrays
import h5py, nrrd
import numpy as np
# data paths
data_path = '/groups/scicompsoft/home/fleishmang/rnr-exm-work/validation_data/zebrafish_pair4.h5'
hdf5_file = h5py.File(data_path, 'r')
fix = hdf5_file['/fixed'][...]
mov = hdf5_file['/move'... |
ff2c5384a46ba97f17f0cf2f3bc177b7c176cdd56596d8d994601d0bd1d51b77 | Jupyter | 2,776 | 103 | # %% [markdown]
# # PhyloGPN demo
#
# Load PhyloGPN through explicit AutoClass registration, inspect its F81 rate
# parameters and embeddings, convert the rates to nucleotide probabilities, and
# compute the existing C-to-T substitution score.
# %% [markdown]
# ## Setup
# %%
!pip install --quiet "gpn"
# %%
from imp... |
5bafaca492b47762a87bd5ea071e851a64722a7b90d90ee031108e8f2a5e8139 | Jupyter | 2,786 | 93 | # %% [markdown]
# # rmANOVA on agreement values
#
# > **Analysis type**: Single γ (calculations)
# %%
import json
from itertools import combinations_with_replacement
from os.path import join
import numpy as np
import pandas as pd
from dn_utils.misc import tidy_data
from dn_utils.path import path
from statsmodels.sta... |
645090c3cecc7defc20564d63947965a37d52adb054c5064b8e836ac51cd8a69 | Jupyter | 2,795 | 130 | # %%
import os
import nibabel as nib
import boto3
from botocore import UNSIGNED
from botocore.client import Config
import shutil
from pathlib import Path
from nilearn import datasets
from utils.nsd_utils import NSDDataHandler
BUCKET = "natural-scenes-dataset"
ROOT = "nsddata_timeseries/ppdata"
NIFTI_REL_PATH = 'fun... |
93c368236b26dabddacc5d8c649334af8ded268dd8946109eac1ced03f6b98f9 | Jupyter | 2,798 | 79 | # %% [markdown]
# ### Point data for dendrites
#
# Create a dataframe of single value metrics for each dendrite and save as pickle
# %%
import NeuRosetta as nr
import pandas as pd
# we need some specific geometry helpers from NeuRosetta which are not normally exposed:
from NeuRosetta.utils.geometry_utils.basis impor... |
578c460a7e78ebfe62061fc054b387f9a987b25b0bb9df0ba61cc5869d907dc5 | Jupyter | 2,807 | 62 | # %%
import os
import cv2
import numpy as np
def calculate_white_pixels(directory):
# Ask user for the directory if not provided
if not directory:
directory = input("Enter the directory path: ").strip()
# Prepare the output file
output_file = os.path.join(directory, "white_pixel_summary-mito.t... |
4b3d0a99bb73160985ef085d9bef6a1ff77ab80ac830502f117ee29187b80db5 | Jupyter | 2,836 | 132 | # %%
%matplotlib inline
%reset
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pickle
import skfda
import sys
from scipy.integrate import simpson
from skfda.preprocessing.dim_reduction import FPCA
from skfda.representation.basis import BSplineBasis
sys.path.append("[insert root path]/f... |
721e1e19787fd585adae2b5beeee20ee390fe1aa9710e4c74d7374d330dc5626 | Jupyter | 2,836 | 58 | # %% [markdown]
# # Explain an Intermediate Layer of VGG16 on ImageNet
#
# Explaining a prediction in terms of the original input image is harder than explaining the predicition in terms of a higher convolutional layer (because the higher convolutional layer is closer to the output). This notebook gives a simple examp... |
aea5d68abdb1f59834a4de08d92091296c29124b6ccc1aa179f85d3e73b7a70a | Jupyter | 2,848 | 66 | # %% [markdown]
#
#
# # Tutorial 2: Types of Surfaces
#
# This tutorial covers what types of surfaces that can be plotted with
# ``surfplot``.
#
# ## Types of surfaces
#
# Put briefly, ``surfplot`` can take file paths to any valid surface file(s)
# with geometry data. Under the hood, :class:`~surfplot.plotting.... |
05da7a0ad85cc85a5bef1991e0c4e36ed8e9dc1e0ecc22cb483fe772a765f736 | Jupyter | 2,874 | 132 | # %%
%matplotlib inline
%reset
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pickle
import skfda
import sys
from scipy.integrate import simpson
from skfda.preprocessing.dim_reduction import FPCA
from skfda.representation.basis import BSplineBasis
sys.path.append("/Users/sambe/Documen... |
37bbd1407f64bca4764f3e436a04215833debb98446ae454fe4331bdcb8195c6 | Jupyter | 2,920 | 96 | # %% [markdown]
#
#
# # Tutorial 6: Regions and Parcellations
#
# This tutorial demonstrates how to plot brain regions.
#
# Regions and parcellations can be plotted with ``brainplot`` as one or more
# layers, and it's possible to add region outlines by simply adding a layer with
# the `as_outline` parameter.
#
# ... |
3c10d997c38de4159c64c1f3bddf9abfe01c05569b42f452edc0be6c8d6824df | Jupyter | 2,930 | 112 | # %% [markdown]
# # Import packages
# %%
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from figure_functions import plot_trajectory
from utils import wrapToPi
# %% [markdown]
# # Load stimuli file
# %% [markdown]
# ### If csv:
# %%
filename = 'model-stims_bio-validati... |
be930f4e052904e8a1c8184059ac3b92f6b23cdd553d8c2d4799799bf61218f5 | Jupyter | 2,932 | 71 | # %% [markdown]
# # Explain an Intermediate Layer of VGG16 on ImageNet (PyTorch)
#
# Explaining a prediction in terms of the original input image is harder than explaining the predicition in terms of a higher convolutional layer (because the higher convolutional layer is closer to the output). This notebook gives a si... |
d5eb781a9fdcbcd171319f8c17b9b9534c9bea18a3de0d550dcd4e7e5417219b | Jupyter | 2,932 | 84 | # %% [markdown]
# # Robustness
# In this example we analyze how robust feature selection with BINN is. All feature selection methods are data-greedy, meaning that we need many samples to generate robust estimations of feature importance. One way to analyze this is to train and explain several models, and compare their ... |
661ed5cb417a65c48389d8049de3761a2a89d51dec982ced2126c49ad3139843 | Jupyter | 2,972 | 114 | # %%
%pylab inline
import scanpy as sc
import pandas as pd
# %%
def postprocess(adata,view=True):
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
sc.pp.highly_variable_genes(adata)
adata.raw = adata
adata = adata[:, adata.var.highly_variable]
print('after select HVG',adata.shape... |
0a6c4db6f5d398395036b1d06c06345e5f49bf200f015db5e5d961c6b8a09449 | Jupyter | 3,011 | 91 | # %% [markdown]
# # Census income classification with Keras
#
# To download a copy of this notebook visit [github](https://github.com/slundberg/shap/tree/master/notebooks).
# %%
from sklearn.model_selection import train_test_split
from keras.layers import Input, Dense, Flatten, Concatenate, concatenate, Dropout, Lamb... |
04f7d1a86754a65b9b6adea17c01f150002d21aa7b50981cb65d771489bb747e | Jupyter | 3,020 | 102 | # %%
# Importing standard libraries
import os
import gc
import sys
import warnings
# Importing data manipulation and scientific computation libraries
import pandas as pd
import numpy as np
import scanpy as sc
import anndata
import scipy.sparse as sparse
# Importing machine learning libraries
import torch
import umap
... |
3702365437ecc2c567c2af493cefb2a83c0a00b41f82a50efe8594c0c1be96e3 | Jupyter | 3,035 | 147 | # %%
! pip install fastcluster
# %%
import os
import sys
from os.path import dirname, realpath, join
base_dir = dirname(dirname(os.getcwd()))
sys.path.insert(0, base_dir)
from config_path import PROSTATE_DATA_PATH, PLOTS_PATH
# %%
import pandas as pd
import numpy as np
from os.path import join
from matplotlib import... |
9d84b9c7ffa0189dd1d05bc62d07b79f75ed9c4952e0c2102fa3392710cb62d7 | Jupyter | 3,047 | 85 | # %% [markdown]
# # Extending pgmpy
# %% [markdown]
# It's really easy to extend pgmpy to quickly prototype your ideas. pgmpy has a base abstract class for most of main functionalities like: `BaseInference` for inference, `BaseFactor` for model parameters, `BaseEstimators` for parameter and model learning. For adding ... |
7fd480c620e6c5bfb1b190f1ba29ab25fe49440d63d1aa8bbdcea3a2c126d59c | Jupyter | 3,073 | 85 | # %%
import numpy as np
from scipy import stats
import pandas as pd
'''
返回四个星号,表示非常显著;
如果p-value < 0.01,则返回三个星号(*),表示非常显著;
如果p-value < 0.05,则返回两个星号(),表示显著;
如果p-value < 0.1,则返回一个星号(*),表示趋近显著;
如果p-value ≥ 0.1,则不返回任何星号,表示不显著。
'''
def pairedT(before, after):
t_statistic, p_value = stats.ttest_rel(before, after)
pri... |
613db8f746138b8f0d05a333677f86e54b90c9aed25b3042dc0a1461146041da | Jupyter | 3,080 | 71 | # %% [markdown]
# ##### **Code for calculating the P1, P2, and Total proportion of time the ant interacts with the larva. The duration of the P1 phase is also recorded.**
# ##### This script requires the files 'timedata_C*.csv', 'TransitionPoints.csv' and 'stats_corrected.csv' resulting from Code_1, Code_3, and manual ... |
16fc0307fbd109c5d267d99be8a510a8f726ca71304ffd1c91a962e3c222a391 | Jupyter | 3,090 | 74 | # %%
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import cross_val_score, StratifiedKFold
from scipy.stats import pearsonr
from counterbalance import CounterbalancedStratifiedSplit
%matplotlib inline
# %%
N = 1000
y = np.repeat([0, ... |
8a971e397d9937bef5f31ea4251ccf38c47bf6e80e6445bd8bdb88704b54e452 | Jupyter | 3,114 | 92 | # %% [markdown]
# # Front Page DeepExplainer MNIST Example
#
# A simple example showing how to explain an MNIST CNN trained using Keras with DeepExplainer.
# %%
# this is the code from https://github.com/keras-team/keras/blob/master/examples/mnist_cnn.py
from __future__ import print_function
import keras
from keras.d... |
c3b7b605d20e89348cc642d3b0964a9b17044f0ffad3f517af1c75ce7e80331e | Jupyter | 3,128 | 92 | # %% [markdown]
# # ImageNet VGG16 Model with Keras
#
# This notebook demonstrates how to use the model agnostic Kernel SHAP algorithm to explain predictions from the VGG16 network in Keras.
# %%
import keras
from keras.applications.vgg16 import VGG16, preprocess_input, decode_predictions
from keras.preprocessing imp... |
7c1e40fe62f3cc0a34b328fbde55c9807e6fceecdcfbdcdfe53a27fa898274d9 | Jupyter | 3,135 | 98 | # %% [markdown]
# ## Neural Population Control
# #### Pipeline for roi and testing the encoding models, performing in-silico ephys and generating the most-exciting images (MEIs)
# %% [markdown]
# Change below the constants that pertain to your experiment, such as names/dates/conditions, and setup info (pixels per degr... |
8ed1a770091f3e3bbde8b22f0ea4090110111c3e8bbac691d187023328da2a70 | Jupyter | 3,141 | 92 | # %% [markdown]
# # Running MMS-LID inference in Colab
# %% [markdown]
# ## Step 1: Clone fairseq-py and install latest version
# %%
import os
!git clone https://github.com/pytorch/fairseq
# Change current working directory
!pwd
%cd "/content/fairseq"
!pip install --editable ./
!pip install tensorboardX
# %% [ma... |
842e7072dc522064ba7c57c9b18ae911b4a39132516cc35cc58a765318f63136 | Jupyter | 3,155 | 91 | # %% [markdown]
# # Sentiment Analysis with Logistic Regression
#
# This gives a simple example of explaining a linear logistic regression sentiment analysis model using shap. Note that with a linear model the SHAP value for feature i for the prediction $f(x)$ (assuming feature independence) is just $\phi_i = \beta_i ... |
44b2294584610b81856badb2c2dfde1b5f3b916bceef6db8532ae32dc7eb0c90 | Jupyter | 3,163 | 143 | # %%
%matplotlib inline
%reset
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pickle
import skfda
import sys
from scipy.integrate import simpson
from skfda.preprocessing.dim_reduction import FPCA
from skfda.representation.basis import BSplineBasis
sys.path.append("[insert root path]/f... |
8e7be68d659fe9c72fe98bcc3a1e2a6703a01706595f17723940fb23ac719900 | Jupyter | 3,177 | 67 | # %% [markdown]
# # **Learning a signed graph from GSD Dataset**
#
# In this notebook, we will learn a signed graph from GSD dataset, taken from [1] and also studied in
# the paper. We start with importing necessary packages.
# %%
import os
import pandas as pd # to load read GSD dataset
import numpy as np
im... |
80ba0259c7317e452be3bd89b038170f2696ca9bfb01f0d9b0b8f9fb0cd758fd | Jupyter | 3,201 | 143 | # %%
%matplotlib inline
%reset
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pickle
import skfda
import sys
from scipy.integrate import simpson
from skfda.preprocessing.dim_reduction import FPCA
from skfda.representation.basis import BSplineBasis
sys.path.append("/Users/sambe/Documen... |
fb4128d5cc5c43da5e32f1adf44c7ed97265e92196e9511f0a60500a29279418 | Jupyter | 3,248 | 140 | # %%
import sys
import os
from os.path import dirname, realpath, join
base_dir = dirname(dirname(os.getcwd()))
import itertools
import pandas as pd
from os.path import join
base_dir
# %%
sys.path.insert(0, base_dir)
from config_path import PROSTATE_DATA_PATH, PLOTS_PATH, GENE_PATH
from data.data_access import Data
# ... |
7912f6f44180cd6258bedc9de038ccc510de85676740bbf1d28a76ec1e985bdd | Jupyter | 3,253 | 128 | # %% [markdown]
# # Causal Inference Examples
# %% [markdown]
# ## Simpson's paradox
# %%
from pgmpy.models import DiscreteBayesianNetwork
from pgmpy.inference import VariableElimination
from pgmpy.factors.discrete import TabularCPD
from pgmpy.inference import CausalInference
from pgmpy.global_vars import config
con... |
88a42b842948e8f6dffb8881f330966cc7269206e35c13e73d91af96d387c08e | Jupyter | 3,308 | 116 | # %%
# Script that plots apical areas, NB-NC contact lengths and durations for transcribing and non-transcribing NCs shown in Figure 3
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from scipy.stats import ttest_ind
# Load dataset
df_original = pd.read_csv('CombinedMatrixPreWindowFirstSignF... |
7430b9be9e11fa4c76b05912986c44673f6b9cb82e1bc7312f26cb8865880951 | Jupyter | 3,312 | 120 | # %% [markdown]
# # Diabetes regression with scikit-learn
#
# This uses the model-agnostic KernelExplainer and the TreeExplainer to explain several different regression models trained on a small diabetes dataset. This notebook is meant to give examples of how to use KernelExplainer for various models.
# %% [markdown]... |
d9b4f2919200cafa78d8ac330b33ec83fdfb20c0c58fe14998a98355a369befc | Jupyter | 3,312 | 114 | # %%
from dn_utils.path import path
from os.path import join
import numpy as np
import json
import pandas as pd
from dn_utils.style import POWER_COLORS, BLUE, ORANGE
from dn_utils.networks import networks_mean
from itertools import combinations_with_replacement
from statsmodels.stats.anova import AnovaRM
from dn_utils.... |
54ebef03950ae070bced9180199e7715a7d0bd6621fea5f3b2cb5adfcac64a8f | Jupyter | 3,351 | 118 | # %%
# IO packages
from aicsimageio import AICSImage
import os
import imageio
# calculation packages
import numpy as np
# segmentation packages
from aicssegmentation.core.pre_processing_utils import intensity_normalization, image_smoothing_gaussian_slice_by_slice
from aicssegmentation.core.seg_dot import dot_3d_wrapp... |
2fd1e7b86e0b3bcfa96d0ef1218062bc91f67d33a857d69aa211189a8e5d6e41 | Jupyter | 3,358 | 106 | # %% [markdown]
# # Inference with Isoformer
#
# This notebook demonstrates how to use the Isoformer model for multi-omics data analysis and gene expression prediction. It shows how to load the model, process DNA, RNA, and protein sequences, and perform inference to predict gene expression levels.
#
# For Google Cola... |
2052388ba34c4ded21f00f37436b1fa7529530e462fa0bb4970f33ff4ae9eb40 | Jupyter | 3,371 | 99 | # %%
import sys
import scanpy as sc
import anndata
import pandas as pd
import numpy as np
import os
import gc
import matplotlib as mpl
from matplotlib import rcParams
import matplotlib.pyplot as plt
import seaborn as sns
import scipy.sparse as sparse
from scvi.data import synthetic_iid
from scvi.dataloaders import AnnD... |
2d245bec6ae30744cc75fbf038d025aed436a86ebbd8dbec39de5032c5a05696 | Jupyter | 3,375 | 171 | # %%
import sys
import os
from os.path import dirname, realpath, join
base_dir = dirname(dirname(os.getcwd()))
import itertools
import pandas as pd
from os.path import join
base_dir
sys.path.insert(0, base_dir)
from config_path import PROSTATE_DATA_PATH, PLOTS_PATH, GENE_PATH
from data.data_access import Data
# %% [... |
5b18d597df31d6fc3ab51bfa9b62ba742c3f49cea62451945663d319dbcef647 | Jupyter | 3,381 | 97 | # %%
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import chi2, norm
# %%
def read_sumstats(ss_fname, ss_id, df_dict, usecols=["P"], sep=None):
if sep:
df = pd.read_csv(ss_fname, usecols=usecols, sep=sep)
else:
df = pd.read_csv(ss_fname, usecols=usecols... |
5df9a21bdcb8399fa4899a0bf4018faeaef39d6d59e15a12538b1512b5331871 | Jupyter | 3,387 | 156 | # %% [markdown]
# # Load & Parse Data
# %%
from utils.parse_data import load_dataset_main
from pathlib import Path
data_path = Path("data/train_pooled_stratified_share_vc")
dataset, device = load_dataset_main(data_path)
# %% [markdown]
# # Train Model
# %%
import importlib
import utils.training
importlib.reload(ut... |
73030d1949fc0737ab66303d3ccdb7ff93c776f1ba79ce7f0813eb05382e5846 | Jupyter | 3,398 | 100 | # %% [markdown]
# # Installing software for this notebook
# See: https://github.com/broadinstitute/Drop-seq/tree/master/src/python to directions on how to install the python code this notebook depends on.
#
# For now, create a new conda env, install 3rd party libs, then install our source code.
#
# ```
# conda remove... |
86bfa14329ec41ac1388b13e9bee21b8a9613ba3572f73da14df9819086be5dc | Jupyter | 3,400 | 77 | # %% [markdown]
# # Precomputed GPN-Star scores
#
# This workflow annotates the real [`songlab/omim_traitgym`](https://huggingface.co/datasets/songlab/omim_traitgym) Mendelian regulatory-variant benchmark from the GPN-Star collection with the public [`songlab/gpn-star-scores`](https://huggingface.co/datasets/songlab/g... |
0b11dc276941ad06afc0eff962457fd4e1765e975ad76aa63b0c607719cbff2d | Jupyter | 3,407 | 131 | # %%
import h5py
import numpy as np
import torch
import matplotlib.pyplot as plt
from torch.utils.data import TensorDataset, DataLoader
from DeepMathedFilterModel import DeepMatchedDetector
device = torch.device("mps" if torch.backends.mps.is_available() else "cpu")
detector_model = DeepMatchedDetector()
detector_mod... |
5fe28c6ce395c28f300abd0d07802f690592826bf7674ee2130b23f84bf3c53e | Jupyter | 3,412 | 83 | # %% [markdown]
# ## Calculating trial-wise parametric modulations
#
# This script calculates values of model variables like value estimation or prediction error for each trial. Script features:
# - loads point estimations of model parameters (e.g. learning rates)
# - calculates trial-wise estimates of different model... |
c433d057910dd24776dbf72f1bfd321abc694645fceb8fee53e031bd2d321096 | Jupyter | 3,413 | 120 | # %% [markdown]
# # Creating a BINN
#
# This notebook demonstrates some examples on how a BINN can be created and trained.
#
# The method begins with constructing a directed graph representing biological pathways, mapping input features (e.g., proteins or genes) to nodes within the network. This graph is manipulated ... |
c98c3fe10feb56f33272ec0649c555a5302292f567856a9eab68a4799a0b1510 | Jupyter | 3,420 | 105 | # %%
%load_ext autoreload
%autoreload 2
# %%
from celltype_ibl.models.BiModalEmbedding import BimodalEmbeddingModel
import torch
import numpy as np
from joblib import load
from celltype_ibl.utils.ibl_data_util import get_ibl_wvf_acg_pairs
latent_dim=512
encode_model = BimodalEmbeddingModel(
layer_norm=Fal... |
f553bac4b4cd2cff024b5d825c09b7ed3df2c5d94d49422030fdf72aeac5453c | Jupyter | 3,463 | 112 | # %%
from dn_utils.path import path
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from os.path import join
import json
from dn_utils.misc import tidy_data
from statsmodels.stats.anova import AnovaRM
import seaborn as sns
from dn_utils.style import ORANGE, BLUE
from statsmodels.stats.multitest i... |
40f804ae621e4d5bc8bc98a62830641acde7256990912c56f6adeadc8486ec56 | Jupyter | 3,474 | 116 | # %% [markdown]
# # Junction Tree Exact Inference
# %% [markdown]
# This example demonstrates how to construct a Junction Tree, define clique potentials and perform exact inference using belief propagation. We will model a simple chain of influence regarding university admission:
# 1. Difficulty (D) of a course affect... |
92acd201b3d34f1bf72255de4f283e9042be6e8ac5ab58eb1dca472109e225bb | Jupyter | 3,489 | 112 | # %%
from pathlib import Path
import pandas as pd
import json
import interpro_proto_go_term_comparison as ipgtc
with open("../data/test_interpro.json", "r") as f:
interpro = json.load(f)
interpro2go = ipgtc.load_interpro2go("../data/interpro2go.txt")
mf_go_ids = ipgtc.load_molecular_function_go_ids("../data/go-bas... |
a1d8c687ad28735e82963beec9e19c08902bd2861fd0d8f021b59956a5fc9297 | Jupyter | 3,497 | 146 | # %% [markdown]
# ## Inputs
# ---
# %%
# reading data and working with arrays
import h5py, nrrd
import numpy as np
# data paths
data_path = '/groups/scicompsoft/home/fleishmang/rnr-exm-work/data/c_elegan_pair3.h5'
hdf5_file = h5py.File(data_path, 'r')
fix = hdf5_file['/fixed'][...]
mov = hdf5_file['/move'][...]
# as... |
7ad75d3aa480ff60eb57c923818581d812cbfb1b048d08a3d62a9c945738c54e | Jupyter | 3,504 | 121 | # %% [markdown]
# # Learning Tree-augmented Naive Bayes (TAN) Structure from Data
# %% [markdown]
# In this notebook, we show an example for learning the structure of a Bayesian Network using the TAN algorithm. We will first build a model to generate some data and then attempt to learn the model's graph structure bac... |
6966b35221802c7a355aa2b5d24ed5244f4e54deecd8141a996214453a6416b6 | Jupyter | 3,540 | 121 | # %%
import torch
from utils import (
load_config,
load_model,
create_metadata_tensor,
load_slices,
transform_to_hu,
window,
zoom_resize,
normalise_slices,
create_channels,
calculate_optimal_slice,
extract_optimal_range,
)
import matplotlib.pyplot as plt
from pathlib import P... |
4d13232b4ef1509af92eaa304f1af82e7f1b0b3273baa6260fe7a97f6d852ae3 | Jupyter | 3,542 | 145 | # %%
import numpy as np
from matplotlib import pyplot as plt
cmap = "Pastel1"
# cmap = "gist_stern"
# %%
fig, ax = plt.subplots()
arr = np.random.rand(6,3)
plt.imshow(arr, extent=[0, 600, 0, 1200], cmap=cmap, alpha = 0.9)
plt.xticks([],[])
plt.yticks([],[])
# plt.ytickslabels()
ax.spines['top'].set_visible(False)
ax... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.