Git Product home page Git Product logo

pertpy-tutorials's Introduction

orphan
true

pertpy-tutorials

This repository hosts all tutorials for pertpy. They are automatically run on pull requests against pertpy.

Please refer to the pertpy documentation for rendered versions.

pertpy-tutorials's People

Contributors

antschum avatar emdann avatar hrovatin avatar isramekki0 avatar johannesostner avatar koncopd avatar lilly-may avatar mingzedong avatar moinfar avatar moomboh avatar stefanpeidli avatar tessadgreen avatar wxicu avatar xinyuejohn avatar yugeji avatar zethson avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pertpy-tutorials's Issues

Add synergy to CINEMA-OT example

Since the full CINEMA-OT dataset (containing all three stimulations) is now available via a dataloader (or will be as soon as the PR is merged), I would suggest adding a section on synergy in the tutorial. The example provided in the documentation demonstrates the general usage but doesn't illustrate how to downstream process the result of the synergy method.

The following code can be used for the tutorial:

adata = pt.dt.cinemaot_full()
sc.pp.pca(adata)
model = pt.tl.Cinemaot()
combo = model.synergy(adata,pert_key='perturbation',base='No stimulation',A='IFNb',B='IFNg',AB='IFNb+ IFNg',thres=0.5,smoothness=1e-5,eps=1e-3,solver='Sinkhorn')
sc.pp.pca(combo)
sc.pp.neighbors(combo)
sc.tl.umap(combo)
synergyscore = np.linalg.norm(combo.X[:,np.abs(np.mean(combo.X,axis=0))>0.15],axis=1)
sc.pl.umap(combo,color=['cell_type0528'],wspace=0.5,size=0.3*synergyscore**2)

Question on scgen_perturbation_prediction.ipynb

Hello pertpy developer,

@Zethson

Thank you for developing this great package and its associated tutorials scgen_perturbation_prediction.ipynb. I run the model.train but meet the following errors. Do you know how to address them? Look forward to learning from your insights. Many thanks in advance!

model.train(max_epochs=100, batch_size=32, early_stopping=True, early_stopping_patience=25)

Traceback (most recent call last):
File "", line 1, in
File "/Users/soopo/.pyenv/versions/3.9.10/lib/python3.9/site-packages/scvi/model/base/_training_mixin.py", line 78, in train
runner = self._train_runner_cls(
File "/Users/soopo/.pyenv/versions/3.9.10/lib/python3.9/site-packages/scvi/train/_trainrunner.py", line 85, in init
self.trainer = self._trainer_cls(
File "/Users/soopo/.pyenv/versions/3.9.10/lib/python3.9/site-packages/scvi/train/_trainer.py", line 139, in init
super().init(
File "/Users/soopo/.pyenv/versions/3.9.10/lib/python3.9/site-packages/lightning/pytorch/utilities/argparse.py", line 70, in insert_env_defaults
return fn(self, **kwargs)
File "/Users/soopo/.pyenv/versions/3.9.10/lib/python3.9/site-packages/lightning/pytorch/trainer/trainer.py", line 399, in init
self._accelerator_connector = _AcceleratorConnector(
File "/Users/soopo/.pyenv/versions/3.9.10/lib/python3.9/site-packages/lightning/pytorch/trainer/connectors/accelerator_connector.py", line 157, in init
self._set_parallel_devices_and_init_accelerator()
File "/Users/soopo/.pyenv/versions/3.9.10/lib/python3.9/site-packages/lightning/pytorch/trainer/connectors/accelerator_connector.py", line 390, in _set_parallel_devices_and_init_accelerator
self._devices_flag = accelerator_cls.parse_devices(self._devices_flag)
File "/Users/soopo/.pyenv/versions/3.9.10/lib/python3.9/site-packages/lightning/pytorch/accelerators/cpu.py", line 48, in parse_devices
return _parse_cpu_cores(devices)
File "/Users/soopo/.pyenv/versions/3.9.10/lib/python3.9/site-packages/lightning/fabric/accelerators/cpu.py", line 85, in _parse_cpu_cores
raise TypeError("devices selected with CPUAccelerator should be an int > 0.")
TypeError: devices selected with CPUAccelerator should be an int > 0.

Bugs in Distance metrics tutorial

In it's current version, the Distance metrics tutorial throws several errors. Most of them can be easily fixed by implementing the following things:

  • Remove verbose as a parameter from pairwise method whenever it's used in the tutorial
  • Specify that 'X_pca' is the obsm_key parameter when initializing a Distance object (obsm_key='X_pca')
  • Use correct distance name: There is one section titled PseudobulkDistance and a Distance object is initialized with the distance 'pseudobulk'. This distance, however, doesn't exist, hence an error is thrown. Is it possible that pseudobulk was renamed and is now called euclidean?

All those things are easily fixed, I just need conformation on the distance that is supposed to be used in the Pseudobulk section.

Got an error when using 'random_forest_regressor' estimator

Since my data had four timepoints-treated conditions, I tried to use 'random_forest_regressor ' estimator which was described for continuous data in the tutorial:
augur = pt.tl.Augur("random_forest_regressor")
treat_augur=augur.load(treat,label_col='group',cell_type_col='celltype')
treat_augur, treat_augur_results = augur.predict(treat_augur, random_state=None, n_threads=4)
However, I got an error in the predicting step:
AttributeError: RandomForestRegressor has none of the following attributes: predict_proba.
What should I do?

sccoda tutorial formatting off

First, the summary shows an overview over the model properties: * Number of samples/cell types * The reference cell type. * The formula used

bugs in scGen tutorial

Currently on pertpy version 0.6.0.

  • cell 4: train.obs["condition"] raises KeyError: 'condition'. You actually want train.obs["label"] == "stim")
  • similarly, "condition" should be replaced with "label" for the rest of the notebook
  • "Let’s remove stimulated CD4T cells from both the training set. This is just for the sake of this notebook, in practice, you do not need to do this step" this is incorrect. You're removing CD4T cells because you want to generalize your stimulated condition to them.
  • cell 7 does not work on cpu or non-jax gpu, raising the following:
    RuntimeError: Backend 'cuda' failed to initialize: module 'jaxlib.xla_extension' has no attribute 'GpuAllocatorConfig'. Available backends are ['cpu']
    You need to add the parameter accelerator='cpu'
  • cell type names have been changed, specifically from "CD4T" to "CD4 T cells"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.