rectanglepy 0.5.0__tar.gz → 0.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/.bumpversion.cfg +1 -1
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/PKG-INFO +9 -6
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/README.md +8 -5
- rectanglepy-0.5.1/docs/_static/rec_logo.001.png +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/docs/conf.py +19 -3
- rectanglepy-0.5.1/docs/notebooks/example.ipynb +551 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/pyproject.toml +1 -1
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/src/rectanglepy/pp/create_signature.py +3 -0
- rectanglepy-0.5.0/docs/notebooks/example.ipynb +0 -324
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/.cruft.json +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/.editorconfig +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/.github/workflows/build.yaml +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/.github/workflows/release.yaml +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/.github/workflows/release_testpypi.yaml +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/.github/workflows/test.yaml +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/.gitignore +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/.pre-commit-config.yaml +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/.readthedocs.yaml +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/CHANGELOG.md +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/LICENSE +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/docs/Makefile +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/docs/_static/.gitkeep +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/docs/_templates/.gitkeep +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/docs/_templates/autosummary/class.rst +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/docs/api.md +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/docs/changelog.md +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/docs/contributing.md +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/docs/extensions/typed_returns.py +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/docs/index.md +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/docs/make.bat +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/docs/references.bib +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/docs/references.md +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/src/rectanglepy/__init__.py +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/src/rectanglepy/data/hao1_annotations_small.zip +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/src/rectanglepy/data/hao1_counts_small.zip +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/src/rectanglepy/data/small_fino_bulks.zip +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/src/rectanglepy/pp/__init__.py +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/src/rectanglepy/pp/rectangle_signature.py +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/src/rectanglepy/rectangle.py +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/src/rectanglepy/tl/__init__.py +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/src/rectanglepy/tl/deconvolution.py +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/tests/data/TIL10_signature.txt +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/tests/data/bulk_small.csv +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/tests/data/cell_annotations_small.txt +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/tests/data/quanTIseq_SimRNAseq_mixture_smaller.csv +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/tests/data/quanTIseq_SimRNAseq_read_fractions_small.txt +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/tests/data/sc_object_small.csv +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/tests/data/signature_hao1.csv +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/tests/test_pp.py +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/tests/test_rectangle.py +0 -0
- {rectanglepy-0.5.0 → rectanglepy-0.5.1}/tests/test_tl.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rectanglepy
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: Hierarchical deconvolution of bulk transcriptomics
|
|
5
5
|
Project-URL: Documentation, https://rectanglepy.readthedocs.io/
|
|
6
6
|
Project-URL: Source, https://github.com/ComputationalBiomedicineGroup/Rectangle
|
|
@@ -64,10 +64,13 @@ Description-Content-Type: text/markdown
|
|
|
64
64
|
[link-tests]: https://github.com/ComputationalBiomedicineGroup/Rectangle/actions/workflows/build.yaml
|
|
65
65
|
[badge-docs]: https://img.shields.io/readthedocs/rectanglepy
|
|
66
66
|
|
|
67
|
-
Rectangle
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
Rectangle is an open-source Python package developed for computational deconvolution.
|
|
68
|
+
|
|
69
|
+
Rectangle presents a novel approach to second-generation deconvolution, characterized by hierarchical processing,
|
|
70
|
+
an estimation of unknown cellular content and a significant reduction in data volume during signature matrix computation.
|
|
71
|
+
|
|
72
|
+
Rectangle was developed to outperform existing deconvolution solutions by introducing methods that promise
|
|
73
|
+
improvements in cell-type fraction estimation accuracy while keeping a low computational profile.
|
|
71
74
|
|
|
72
75
|
## Getting started
|
|
73
76
|
|
|
@@ -77,7 +80,7 @@ Please refer to the [documentation][link-docs]. In particular, the
|
|
|
77
80
|
|
|
78
81
|
## Installation
|
|
79
82
|
|
|
80
|
-
You need to have Python 3.10 or
|
|
83
|
+
You need to have Python 3.10 or higher installed on your system. If you don't have
|
|
81
84
|
Python installed, we recommend installing [Mambaforge](https://github.com/conda-forge/miniforge#mambaforge).
|
|
82
85
|
|
|
83
86
|
How to install Rectangle:
|
|
@@ -7,10 +7,13 @@
|
|
|
7
7
|
[link-tests]: https://github.com/ComputationalBiomedicineGroup/Rectangle/actions/workflows/build.yaml
|
|
8
8
|
[badge-docs]: https://img.shields.io/readthedocs/rectanglepy
|
|
9
9
|
|
|
10
|
-
Rectangle
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
Rectangle is an open-source Python package developed for computational deconvolution.
|
|
11
|
+
|
|
12
|
+
Rectangle presents a novel approach to second-generation deconvolution, characterized by hierarchical processing,
|
|
13
|
+
an estimation of unknown cellular content and a significant reduction in data volume during signature matrix computation.
|
|
14
|
+
|
|
15
|
+
Rectangle was developed to outperform existing deconvolution solutions by introducing methods that promise
|
|
16
|
+
improvements in cell-type fraction estimation accuracy while keeping a low computational profile.
|
|
14
17
|
|
|
15
18
|
## Getting started
|
|
16
19
|
|
|
@@ -20,7 +23,7 @@ Please refer to the [documentation][link-docs]. In particular, the
|
|
|
20
23
|
|
|
21
24
|
## Installation
|
|
22
25
|
|
|
23
|
-
You need to have Python 3.10 or
|
|
26
|
+
You need to have Python 3.10 or higher installed on your system. If you don't have
|
|
24
27
|
Python installed, we recommend installing [Mambaforge](https://github.com/conda-forge/miniforge#mambaforge).
|
|
25
28
|
|
|
26
29
|
How to install Rectangle:
|
|
Binary file
|
|
@@ -37,6 +37,8 @@ html_context = {
|
|
|
37
37
|
"github_repo": "Rectangle", # Repo name
|
|
38
38
|
"github_version": "main", # Version
|
|
39
39
|
"conf_py_path": "/docs/", # Path in the checkout to the docs root
|
|
40
|
+
"repository_url": repository_url,
|
|
41
|
+
"use_repository_button": True,
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
# -- General configuration ---------------------------------------------------
|
|
@@ -103,15 +105,29 @@ exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]
|
|
|
103
105
|
|
|
104
106
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
|
105
107
|
# a list of builtin themes.
|
|
106
|
-
|
|
108
|
+
|
|
107
109
|
html_theme = "furo"
|
|
108
110
|
html_static_path = ["_static"]
|
|
109
111
|
html_title = "rectangle"
|
|
110
112
|
|
|
113
|
+
|
|
114
|
+
html_logo = "_static/rec_logo.001.png"
|
|
115
|
+
|
|
111
116
|
html_theme_options = {
|
|
112
|
-
"repository_url": repository_url,
|
|
113
|
-
"use_repository_button": True,
|
|
114
117
|
"path_to_docs": "docs/",
|
|
118
|
+
"sidebar_hide_name": True, # Hide the project name in the sidebar
|
|
119
|
+
"footer_icons": [
|
|
120
|
+
{
|
|
121
|
+
"name": "GitHub",
|
|
122
|
+
"url": repository_url,
|
|
123
|
+
"html": """
|
|
124
|
+
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
|
|
125
|
+
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
|
|
126
|
+
</svg>
|
|
127
|
+
""",
|
|
128
|
+
"class": "",
|
|
129
|
+
},
|
|
130
|
+
],
|
|
115
131
|
}
|
|
116
132
|
|
|
117
133
|
|
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"metadata": {},
|
|
6
|
+
"source": [
|
|
7
|
+
"# Example workflow"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"cell_type": "markdown",
|
|
12
|
+
"source": [],
|
|
13
|
+
"metadata": {
|
|
14
|
+
"collapsed": false
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"cell_type": "code",
|
|
19
|
+
"metadata": {},
|
|
20
|
+
"source": [
|
|
21
|
+
"import rectanglepy as rectangle\n",
|
|
22
|
+
"from anndata import AnnData"
|
|
23
|
+
],
|
|
24
|
+
"outputs": [],
|
|
25
|
+
"execution_count": null
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"cell_type": "markdown",
|
|
29
|
+
"source": [
|
|
30
|
+
"## Load tutorial data"
|
|
31
|
+
],
|
|
32
|
+
"metadata": {
|
|
33
|
+
"collapsed": false
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"cell_type": "code",
|
|
38
|
+
"metadata": {},
|
|
39
|
+
"source": [
|
|
40
|
+
"sc_counts, annotations, bulks = rectangle.load_tutorial_data()"
|
|
41
|
+
],
|
|
42
|
+
"outputs": [],
|
|
43
|
+
"execution_count": null
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"cell_type": "code",
|
|
47
|
+
"source": "sc_counts.iloc[:, :5].head()",
|
|
48
|
+
"metadata": {
|
|
49
|
+
"collapsed": false,
|
|
50
|
+
"ExecuteTime": {
|
|
51
|
+
"end_time": "2025-01-23T05:46:15.359490Z",
|
|
52
|
+
"start_time": "2025-01-23T05:46:15.352713Z"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"outputs": [
|
|
56
|
+
{
|
|
57
|
+
"data": {
|
|
58
|
+
"text/plain": [
|
|
59
|
+
" MIR1302-2HG AL627309.1 AL627309.4 AC114498.1 \n",
|
|
60
|
+
"E2L4_GATGCTACAGGCACAA 0 0 0 0 \\\n",
|
|
61
|
+
"L5_AACAACCAGGAACTAT 0 0 0 0 \n",
|
|
62
|
+
"L5_TCCTTCTGTACTCCGG 0 0 0 0 \n",
|
|
63
|
+
"L2_GCCCGAACACGTATAC 0 0 0 0 \n",
|
|
64
|
+
"E2L2_ATGCATGTCACACCCT 0 0 0 0 \n",
|
|
65
|
+
"\n",
|
|
66
|
+
" AL669831.5 \n",
|
|
67
|
+
"E2L4_GATGCTACAGGCACAA 0 \n",
|
|
68
|
+
"L5_AACAACCAGGAACTAT 0 \n",
|
|
69
|
+
"L5_TCCTTCTGTACTCCGG 0 \n",
|
|
70
|
+
"L2_GCCCGAACACGTATAC 0 \n",
|
|
71
|
+
"E2L2_ATGCATGTCACACCCT 0 "
|
|
72
|
+
],
|
|
73
|
+
"text/html": [
|
|
74
|
+
"<div>\n",
|
|
75
|
+
"<style scoped>\n",
|
|
76
|
+
" .dataframe tbody tr th:only-of-type {\n",
|
|
77
|
+
" vertical-align: middle;\n",
|
|
78
|
+
" }\n",
|
|
79
|
+
"\n",
|
|
80
|
+
" .dataframe tbody tr th {\n",
|
|
81
|
+
" vertical-align: top;\n",
|
|
82
|
+
" }\n",
|
|
83
|
+
"\n",
|
|
84
|
+
" .dataframe thead th {\n",
|
|
85
|
+
" text-align: right;\n",
|
|
86
|
+
" }\n",
|
|
87
|
+
"</style>\n",
|
|
88
|
+
"<table border=\"1\" class=\"dataframe\">\n",
|
|
89
|
+
" <thead>\n",
|
|
90
|
+
" <tr style=\"text-align: right;\">\n",
|
|
91
|
+
" <th></th>\n",
|
|
92
|
+
" <th>MIR1302-2HG</th>\n",
|
|
93
|
+
" <th>AL627309.1</th>\n",
|
|
94
|
+
" <th>AL627309.4</th>\n",
|
|
95
|
+
" <th>AC114498.1</th>\n",
|
|
96
|
+
" <th>AL669831.5</th>\n",
|
|
97
|
+
" </tr>\n",
|
|
98
|
+
" </thead>\n",
|
|
99
|
+
" <tbody>\n",
|
|
100
|
+
" <tr>\n",
|
|
101
|
+
" <th>E2L4_GATGCTACAGGCACAA</th>\n",
|
|
102
|
+
" <td>0</td>\n",
|
|
103
|
+
" <td>0</td>\n",
|
|
104
|
+
" <td>0</td>\n",
|
|
105
|
+
" <td>0</td>\n",
|
|
106
|
+
" <td>0</td>\n",
|
|
107
|
+
" </tr>\n",
|
|
108
|
+
" <tr>\n",
|
|
109
|
+
" <th>L5_AACAACCAGGAACTAT</th>\n",
|
|
110
|
+
" <td>0</td>\n",
|
|
111
|
+
" <td>0</td>\n",
|
|
112
|
+
" <td>0</td>\n",
|
|
113
|
+
" <td>0</td>\n",
|
|
114
|
+
" <td>0</td>\n",
|
|
115
|
+
" </tr>\n",
|
|
116
|
+
" <tr>\n",
|
|
117
|
+
" <th>L5_TCCTTCTGTACTCCGG</th>\n",
|
|
118
|
+
" <td>0</td>\n",
|
|
119
|
+
" <td>0</td>\n",
|
|
120
|
+
" <td>0</td>\n",
|
|
121
|
+
" <td>0</td>\n",
|
|
122
|
+
" <td>0</td>\n",
|
|
123
|
+
" </tr>\n",
|
|
124
|
+
" <tr>\n",
|
|
125
|
+
" <th>L2_GCCCGAACACGTATAC</th>\n",
|
|
126
|
+
" <td>0</td>\n",
|
|
127
|
+
" <td>0</td>\n",
|
|
128
|
+
" <td>0</td>\n",
|
|
129
|
+
" <td>0</td>\n",
|
|
130
|
+
" <td>0</td>\n",
|
|
131
|
+
" </tr>\n",
|
|
132
|
+
" <tr>\n",
|
|
133
|
+
" <th>E2L2_ATGCATGTCACACCCT</th>\n",
|
|
134
|
+
" <td>0</td>\n",
|
|
135
|
+
" <td>0</td>\n",
|
|
136
|
+
" <td>0</td>\n",
|
|
137
|
+
" <td>0</td>\n",
|
|
138
|
+
" <td>0</td>\n",
|
|
139
|
+
" </tr>\n",
|
|
140
|
+
" </tbody>\n",
|
|
141
|
+
"</table>\n",
|
|
142
|
+
"</div>"
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
"execution_count": 12,
|
|
146
|
+
"metadata": {},
|
|
147
|
+
"output_type": "execute_result"
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"execution_count": 12
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"cell_type": "code",
|
|
154
|
+
"source": [
|
|
155
|
+
"annotations.head()"
|
|
156
|
+
],
|
|
157
|
+
"metadata": {
|
|
158
|
+
"collapsed": false
|
|
159
|
+
},
|
|
160
|
+
"outputs": [],
|
|
161
|
+
"execution_count": null
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"cell_type": "code",
|
|
165
|
+
"source": "bulks.iloc[:, :5].head()",
|
|
166
|
+
"metadata": {
|
|
167
|
+
"collapsed": false,
|
|
168
|
+
"ExecuteTime": {
|
|
169
|
+
"end_time": "2025-01-23T05:46:13.242102Z",
|
|
170
|
+
"start_time": "2025-01-23T05:46:13.235377Z"
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
"outputs": [
|
|
174
|
+
{
|
|
175
|
+
"data": {
|
|
176
|
+
"text/plain": [
|
|
177
|
+
" UBE2Q2P2 SSX9 CXorf67 EFCAB8 SPATA31B1P\n",
|
|
178
|
+
"pbmc_1 0.000000 0.0 0.118865 0.00000 0.0\n",
|
|
179
|
+
"pbmc_10 0.081115 0.0 0.086782 0.00000 0.0\n",
|
|
180
|
+
"pbmc_12 0.000000 0.0 0.188464 0.03157 0.0"
|
|
181
|
+
],
|
|
182
|
+
"text/html": [
|
|
183
|
+
"<div>\n",
|
|
184
|
+
"<style scoped>\n",
|
|
185
|
+
" .dataframe tbody tr th:only-of-type {\n",
|
|
186
|
+
" vertical-align: middle;\n",
|
|
187
|
+
" }\n",
|
|
188
|
+
"\n",
|
|
189
|
+
" .dataframe tbody tr th {\n",
|
|
190
|
+
" vertical-align: top;\n",
|
|
191
|
+
" }\n",
|
|
192
|
+
"\n",
|
|
193
|
+
" .dataframe thead th {\n",
|
|
194
|
+
" text-align: right;\n",
|
|
195
|
+
" }\n",
|
|
196
|
+
"</style>\n",
|
|
197
|
+
"<table border=\"1\" class=\"dataframe\">\n",
|
|
198
|
+
" <thead>\n",
|
|
199
|
+
" <tr style=\"text-align: right;\">\n",
|
|
200
|
+
" <th></th>\n",
|
|
201
|
+
" <th>UBE2Q2P2</th>\n",
|
|
202
|
+
" <th>SSX9</th>\n",
|
|
203
|
+
" <th>CXorf67</th>\n",
|
|
204
|
+
" <th>EFCAB8</th>\n",
|
|
205
|
+
" <th>SPATA31B1P</th>\n",
|
|
206
|
+
" </tr>\n",
|
|
207
|
+
" </thead>\n",
|
|
208
|
+
" <tbody>\n",
|
|
209
|
+
" <tr>\n",
|
|
210
|
+
" <th>pbmc_1</th>\n",
|
|
211
|
+
" <td>0.000000</td>\n",
|
|
212
|
+
" <td>0.0</td>\n",
|
|
213
|
+
" <td>0.118865</td>\n",
|
|
214
|
+
" <td>0.00000</td>\n",
|
|
215
|
+
" <td>0.0</td>\n",
|
|
216
|
+
" </tr>\n",
|
|
217
|
+
" <tr>\n",
|
|
218
|
+
" <th>pbmc_10</th>\n",
|
|
219
|
+
" <td>0.081115</td>\n",
|
|
220
|
+
" <td>0.0</td>\n",
|
|
221
|
+
" <td>0.086782</td>\n",
|
|
222
|
+
" <td>0.00000</td>\n",
|
|
223
|
+
" <td>0.0</td>\n",
|
|
224
|
+
" </tr>\n",
|
|
225
|
+
" <tr>\n",
|
|
226
|
+
" <th>pbmc_12</th>\n",
|
|
227
|
+
" <td>0.000000</td>\n",
|
|
228
|
+
" <td>0.0</td>\n",
|
|
229
|
+
" <td>0.188464</td>\n",
|
|
230
|
+
" <td>0.03157</td>\n",
|
|
231
|
+
" <td>0.0</td>\n",
|
|
232
|
+
" </tr>\n",
|
|
233
|
+
" </tbody>\n",
|
|
234
|
+
"</table>\n",
|
|
235
|
+
"</div>"
|
|
236
|
+
]
|
|
237
|
+
},
|
|
238
|
+
"execution_count": 11,
|
|
239
|
+
"metadata": {},
|
|
240
|
+
"output_type": "execute_result"
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
"execution_count": 11
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"cell_type": "markdown",
|
|
247
|
+
"metadata": {},
|
|
248
|
+
"source": [
|
|
249
|
+
"### Convert to AnnData object"
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"cell_type": "code",
|
|
254
|
+
"source": [
|
|
255
|
+
"sc_adata = AnnData(sc_counts, obs=annotations.to_frame(name=\"cell_type\"))"
|
|
256
|
+
],
|
|
257
|
+
"metadata": {
|
|
258
|
+
"collapsed": false
|
|
259
|
+
},
|
|
260
|
+
"outputs": [],
|
|
261
|
+
"execution_count": null
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"cell_type": "markdown",
|
|
265
|
+
"source": [
|
|
266
|
+
"# Single step Rectangle workflow"
|
|
267
|
+
],
|
|
268
|
+
"metadata": {
|
|
269
|
+
"collapsed": false
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"metadata": {},
|
|
274
|
+
"cell_type": "markdown",
|
|
275
|
+
"source": "To deconvolute the bulk data in a single step, use the rectangle function. This function returns a tuple of the estimated cell type proportions and the signature result."
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"cell_type": "code",
|
|
279
|
+
"source": [
|
|
280
|
+
"estimations, signature_result = rectangle.rectangle(sc_adata, bulks)"
|
|
281
|
+
],
|
|
282
|
+
"metadata": {
|
|
283
|
+
"collapsed": false
|
|
284
|
+
},
|
|
285
|
+
"outputs": [],
|
|
286
|
+
"execution_count": null
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
"cell_type": "code",
|
|
290
|
+
"source": "estimations",
|
|
291
|
+
"metadata": {
|
|
292
|
+
"collapsed": false
|
|
293
|
+
},
|
|
294
|
+
"outputs": [],
|
|
295
|
+
"execution_count": null
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"cell_type": "markdown",
|
|
299
|
+
"source": "signature_result is a [`RectangleSignatureResult`](../generated/rectanglepy.pp.RectangleSignatureResult.rst) object.",
|
|
300
|
+
"metadata": {
|
|
301
|
+
"collapsed": false
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"cell_type": "markdown",
|
|
306
|
+
"source": [
|
|
307
|
+
"# 2-step Rectangle workflow"
|
|
308
|
+
],
|
|
309
|
+
"metadata": {
|
|
310
|
+
"collapsed": false
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
"cell_type": "markdown",
|
|
315
|
+
"source": [
|
|
316
|
+
"Rectangle can also be run in two steps, first creating the signature and then deconvoluting the bulk data."
|
|
317
|
+
],
|
|
318
|
+
"metadata": {
|
|
319
|
+
"collapsed": false
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"cell_type": "markdown",
|
|
324
|
+
"source": [
|
|
325
|
+
"## Create Signature result"
|
|
326
|
+
],
|
|
327
|
+
"metadata": {
|
|
328
|
+
"collapsed": false
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"cell_type": "code",
|
|
333
|
+
"source": [
|
|
334
|
+
"signature_result = rectangle.pp.build_rectangle_signatures(sc_adata, bulks=bulks)"
|
|
335
|
+
],
|
|
336
|
+
"metadata": {
|
|
337
|
+
"collapsed": false
|
|
338
|
+
},
|
|
339
|
+
"outputs": [],
|
|
340
|
+
"execution_count": null
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
"cell_type": "markdown",
|
|
344
|
+
"source": [
|
|
345
|
+
"This creates a [`RectangleSignatureResult`](../generated/rectanglepy.pp.RectangleSignatureResult.rst) object."
|
|
346
|
+
],
|
|
347
|
+
"metadata": {
|
|
348
|
+
"collapsed": false
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"cell_type": "markdown",
|
|
353
|
+
"source": [
|
|
354
|
+
"## Deconvolute bulk data"
|
|
355
|
+
],
|
|
356
|
+
"metadata": {
|
|
357
|
+
"collapsed": false
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"cell_type": "code",
|
|
362
|
+
"source": [
|
|
363
|
+
"estimations = rectangle.tl.deconvolution(signature_result, bulks)"
|
|
364
|
+
],
|
|
365
|
+
"metadata": {
|
|
366
|
+
"collapsed": false
|
|
367
|
+
},
|
|
368
|
+
"outputs": [],
|
|
369
|
+
"execution_count": null
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
"cell_type": "markdown",
|
|
373
|
+
"source": [
|
|
374
|
+
"This returns a pandas DataFrame with the estimated cell type proportions."
|
|
375
|
+
],
|
|
376
|
+
"metadata": {
|
|
377
|
+
"collapsed": false
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"cell_type": "code",
|
|
382
|
+
"source": "estimations.T",
|
|
383
|
+
"metadata": {
|
|
384
|
+
"collapsed": false,
|
|
385
|
+
"ExecuteTime": {
|
|
386
|
+
"end_time": "2025-01-23T05:46:46.255422Z",
|
|
387
|
+
"start_time": "2025-01-23T05:46:46.248810Z"
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
"outputs": [
|
|
391
|
+
{
|
|
392
|
+
"data": {
|
|
393
|
+
"text/plain": [
|
|
394
|
+
" pbmc_1 pbmc_10 pbmc_12\n",
|
|
395
|
+
"B cells 0.089947 1.099018e-01 7.147636e-02\n",
|
|
396
|
+
"ILC 0.008037 1.482882e-02 7.568929e-03\n",
|
|
397
|
+
"Monocytes 0.227473 2.967478e-01 2.255510e-01\n",
|
|
398
|
+
"NK cells 0.022183 1.626444e-02 1.011593e-01\n",
|
|
399
|
+
"Plasma cells 0.005894 6.567050e-04 3.095959e-03\n",
|
|
400
|
+
"Platelet 0.004847 2.190904e-02 1.863999e-02\n",
|
|
401
|
+
"T cells CD4 conv 0.037192 -6.450194e-18 -3.137140e-17\n",
|
|
402
|
+
"T cells CD8 0.161779 1.180941e-01 2.740643e-01\n",
|
|
403
|
+
"Tregs 0.416100 3.962703e-01 2.563935e-01\n",
|
|
404
|
+
"mDC 0.024173 2.066734e-02 1.005506e-02\n",
|
|
405
|
+
"pDC 0.002376 4.659653e-03 2.985398e-03\n",
|
|
406
|
+
"Unknown 0.000000 0.000000e+00 2.901021e-02"
|
|
407
|
+
],
|
|
408
|
+
"text/html": [
|
|
409
|
+
"<div>\n",
|
|
410
|
+
"<style scoped>\n",
|
|
411
|
+
" .dataframe tbody tr th:only-of-type {\n",
|
|
412
|
+
" vertical-align: middle;\n",
|
|
413
|
+
" }\n",
|
|
414
|
+
"\n",
|
|
415
|
+
" .dataframe tbody tr th {\n",
|
|
416
|
+
" vertical-align: top;\n",
|
|
417
|
+
" }\n",
|
|
418
|
+
"\n",
|
|
419
|
+
" .dataframe thead th {\n",
|
|
420
|
+
" text-align: right;\n",
|
|
421
|
+
" }\n",
|
|
422
|
+
"</style>\n",
|
|
423
|
+
"<table border=\"1\" class=\"dataframe\">\n",
|
|
424
|
+
" <thead>\n",
|
|
425
|
+
" <tr style=\"text-align: right;\">\n",
|
|
426
|
+
" <th></th>\n",
|
|
427
|
+
" <th>pbmc_1</th>\n",
|
|
428
|
+
" <th>pbmc_10</th>\n",
|
|
429
|
+
" <th>pbmc_12</th>\n",
|
|
430
|
+
" </tr>\n",
|
|
431
|
+
" </thead>\n",
|
|
432
|
+
" <tbody>\n",
|
|
433
|
+
" <tr>\n",
|
|
434
|
+
" <th>B cells</th>\n",
|
|
435
|
+
" <td>0.089947</td>\n",
|
|
436
|
+
" <td>1.099018e-01</td>\n",
|
|
437
|
+
" <td>7.147636e-02</td>\n",
|
|
438
|
+
" </tr>\n",
|
|
439
|
+
" <tr>\n",
|
|
440
|
+
" <th>ILC</th>\n",
|
|
441
|
+
" <td>0.008037</td>\n",
|
|
442
|
+
" <td>1.482882e-02</td>\n",
|
|
443
|
+
" <td>7.568929e-03</td>\n",
|
|
444
|
+
" </tr>\n",
|
|
445
|
+
" <tr>\n",
|
|
446
|
+
" <th>Monocytes</th>\n",
|
|
447
|
+
" <td>0.227473</td>\n",
|
|
448
|
+
" <td>2.967478e-01</td>\n",
|
|
449
|
+
" <td>2.255510e-01</td>\n",
|
|
450
|
+
" </tr>\n",
|
|
451
|
+
" <tr>\n",
|
|
452
|
+
" <th>NK cells</th>\n",
|
|
453
|
+
" <td>0.022183</td>\n",
|
|
454
|
+
" <td>1.626444e-02</td>\n",
|
|
455
|
+
" <td>1.011593e-01</td>\n",
|
|
456
|
+
" </tr>\n",
|
|
457
|
+
" <tr>\n",
|
|
458
|
+
" <th>Plasma cells</th>\n",
|
|
459
|
+
" <td>0.005894</td>\n",
|
|
460
|
+
" <td>6.567050e-04</td>\n",
|
|
461
|
+
" <td>3.095959e-03</td>\n",
|
|
462
|
+
" </tr>\n",
|
|
463
|
+
" <tr>\n",
|
|
464
|
+
" <th>Platelet</th>\n",
|
|
465
|
+
" <td>0.004847</td>\n",
|
|
466
|
+
" <td>2.190904e-02</td>\n",
|
|
467
|
+
" <td>1.863999e-02</td>\n",
|
|
468
|
+
" </tr>\n",
|
|
469
|
+
" <tr>\n",
|
|
470
|
+
" <th>T cells CD4 conv</th>\n",
|
|
471
|
+
" <td>0.037192</td>\n",
|
|
472
|
+
" <td>-6.450194e-18</td>\n",
|
|
473
|
+
" <td>-3.137140e-17</td>\n",
|
|
474
|
+
" </tr>\n",
|
|
475
|
+
" <tr>\n",
|
|
476
|
+
" <th>T cells CD8</th>\n",
|
|
477
|
+
" <td>0.161779</td>\n",
|
|
478
|
+
" <td>1.180941e-01</td>\n",
|
|
479
|
+
" <td>2.740643e-01</td>\n",
|
|
480
|
+
" </tr>\n",
|
|
481
|
+
" <tr>\n",
|
|
482
|
+
" <th>Tregs</th>\n",
|
|
483
|
+
" <td>0.416100</td>\n",
|
|
484
|
+
" <td>3.962703e-01</td>\n",
|
|
485
|
+
" <td>2.563935e-01</td>\n",
|
|
486
|
+
" </tr>\n",
|
|
487
|
+
" <tr>\n",
|
|
488
|
+
" <th>mDC</th>\n",
|
|
489
|
+
" <td>0.024173</td>\n",
|
|
490
|
+
" <td>2.066734e-02</td>\n",
|
|
491
|
+
" <td>1.005506e-02</td>\n",
|
|
492
|
+
" </tr>\n",
|
|
493
|
+
" <tr>\n",
|
|
494
|
+
" <th>pDC</th>\n",
|
|
495
|
+
" <td>0.002376</td>\n",
|
|
496
|
+
" <td>4.659653e-03</td>\n",
|
|
497
|
+
" <td>2.985398e-03</td>\n",
|
|
498
|
+
" </tr>\n",
|
|
499
|
+
" <tr>\n",
|
|
500
|
+
" <th>Unknown</th>\n",
|
|
501
|
+
" <td>0.000000</td>\n",
|
|
502
|
+
" <td>0.000000e+00</td>\n",
|
|
503
|
+
" <td>2.901021e-02</td>\n",
|
|
504
|
+
" </tr>\n",
|
|
505
|
+
" </tbody>\n",
|
|
506
|
+
"</table>\n",
|
|
507
|
+
"</div>"
|
|
508
|
+
]
|
|
509
|
+
},
|
|
510
|
+
"execution_count": 14,
|
|
511
|
+
"metadata": {},
|
|
512
|
+
"output_type": "execute_result"
|
|
513
|
+
}
|
|
514
|
+
],
|
|
515
|
+
"execution_count": 14
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
"metadata": {},
|
|
519
|
+
"cell_type": "code",
|
|
520
|
+
"outputs": [],
|
|
521
|
+
"execution_count": null,
|
|
522
|
+
"source": ""
|
|
523
|
+
}
|
|
524
|
+
],
|
|
525
|
+
"metadata": {
|
|
526
|
+
"kernelspec": {
|
|
527
|
+
"display_name": "Python 3.9.12 ('squidpy39')",
|
|
528
|
+
"language": "python",
|
|
529
|
+
"name": "python3"
|
|
530
|
+
},
|
|
531
|
+
"language_info": {
|
|
532
|
+
"codemirror_mode": {
|
|
533
|
+
"name": "ipython",
|
|
534
|
+
"version": 3
|
|
535
|
+
},
|
|
536
|
+
"file_extension": ".py",
|
|
537
|
+
"mimetype": "text/x-python",
|
|
538
|
+
"name": "python",
|
|
539
|
+
"nbconvert_exporter": "python",
|
|
540
|
+
"pygments_lexer": "ipython3",
|
|
541
|
+
"version": "3.9.12"
|
|
542
|
+
},
|
|
543
|
+
"vscode": {
|
|
544
|
+
"interpreter": {
|
|
545
|
+
"hash": "ae6466e8d4f517858789b5c9e8f0ed238fb8964458a36305fca7bddc149e9c64"
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
"nbformat": 4,
|
|
550
|
+
"nbformat_minor": 4
|
|
551
|
+
}
|
|
@@ -172,6 +172,7 @@ def _create_bootstrap_signature(countsig, sc_data, annotations) -> pd.DataFrame:
|
|
|
172
172
|
bootstrapped_signature = pd.DataFrame()
|
|
173
173
|
number_of_bootstraps = 7
|
|
174
174
|
samples_per_bootstrap = 500
|
|
175
|
+
np.random.seed(42)
|
|
175
176
|
for celltype in celltypes:
|
|
176
177
|
sc_data_filtered = sc_data.T[annotations == celltype]
|
|
177
178
|
for i in range(number_of_bootstraps):
|
|
@@ -319,8 +320,10 @@ def build_rectangle_signatures(
|
|
|
319
320
|
"""
|
|
320
321
|
annotations = adata.obs[cell_type_col]
|
|
321
322
|
adata = adata[:, adata.X.sum(axis=0) > len(annotations.value_counts())]
|
|
323
|
+
assert adata.var_names.is_unique, "Duplicate gene found in adata"
|
|
322
324
|
|
|
323
325
|
if bulks is not None:
|
|
326
|
+
assert bulks.columns.is_unique, "Duplicate gene found in bulks"
|
|
324
327
|
genes = list(set(bulks.columns) & set(adata.var_names))
|
|
325
328
|
genes = sorted(genes)
|
|
326
329
|
assert len(genes) > 0, "No common genes between bulks and single-cell data"
|
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"cells": [
|
|
3
|
-
{
|
|
4
|
-
"cell_type": "markdown",
|
|
5
|
-
"metadata": {},
|
|
6
|
-
"source": [
|
|
7
|
-
"# Example workflow"
|
|
8
|
-
]
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"cell_type": "markdown",
|
|
12
|
-
"source": [],
|
|
13
|
-
"metadata": {
|
|
14
|
-
"collapsed": false
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"cell_type": "code",
|
|
19
|
-
"execution_count": 1,
|
|
20
|
-
"metadata": {
|
|
21
|
-
"ExecuteTime": {
|
|
22
|
-
"end_time": "2024-03-25T16:12:40.629887Z",
|
|
23
|
-
"start_time": "2024-03-25T16:12:39.074585Z"
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"outputs": [],
|
|
27
|
-
"source": [
|
|
28
|
-
"import rectanglepy as rectangle\n",
|
|
29
|
-
"from anndata import AnnData"
|
|
30
|
-
]
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"cell_type": "markdown",
|
|
34
|
-
"source": [
|
|
35
|
-
"## Load tutorial data"
|
|
36
|
-
],
|
|
37
|
-
"metadata": {
|
|
38
|
-
"collapsed": false
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"cell_type": "code",
|
|
43
|
-
"execution_count": 2,
|
|
44
|
-
"metadata": {
|
|
45
|
-
"ExecuteTime": {
|
|
46
|
-
"end_time": "2024-03-25T16:12:41.282874Z",
|
|
47
|
-
"start_time": "2024-03-25T16:12:40.630684Z"
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
"outputs": [],
|
|
51
|
-
"source": [
|
|
52
|
-
"sc_counts, annotations, bulks = rectangle.load_tutorial_data()"
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"cell_type": "code",
|
|
57
|
-
"execution_count": 3,
|
|
58
|
-
"outputs": [
|
|
59
|
-
{
|
|
60
|
-
"data": {
|
|
61
|
-
"text/plain": " MIR1302-2HG AL627309.1 AL627309.4 AC114498.1 \nE2L4_GATGCTACAGGCACAA 0 0 0 0 \\\nL5_AACAACCAGGAACTAT 0 0 0 0 \nL5_TCCTTCTGTACTCCGG 0 0 0 0 \nL2_GCCCGAACACGTATAC 0 0 0 0 \nE2L2_ATGCATGTCACACCCT 0 0 0 0 \n\n AL669831.5 FAM41C AL645608.5 NOC2L PERM1 ISG15 \nE2L4_GATGCTACAGGCACAA 0 0 0 0 0 7 \nL5_AACAACCAGGAACTAT 0 0 0 0 0 1 \nL5_TCCTTCTGTACTCCGG 0 0 0 0 0 0 \nL2_GCCCGAACACGTATAC 0 0 0 0 0 2 \nE2L2_ATGCATGTCACACCCT 0 1 0 0 0 1 ",
|
|
62
|
-
"text/html": "<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>MIR1302-2HG</th>\n <th>AL627309.1</th>\n <th>AL627309.4</th>\n <th>AC114498.1</th>\n <th>AL669831.5</th>\n <th>FAM41C</th>\n <th>AL645608.5</th>\n <th>NOC2L</th>\n <th>PERM1</th>\n <th>ISG15</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>E2L4_GATGCTACAGGCACAA</th>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>7</td>\n </tr>\n <tr>\n <th>L5_AACAACCAGGAACTAT</th>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1</td>\n </tr>\n <tr>\n <th>L5_TCCTTCTGTACTCCGG</th>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n </tr>\n <tr>\n <th>L2_GCCCGAACACGTATAC</th>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>2</td>\n </tr>\n <tr>\n <th>E2L2_ATGCATGTCACACCCT</th>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>1</td>\n </tr>\n </tbody>\n</table>\n</div>"
|
|
63
|
-
},
|
|
64
|
-
"execution_count": 3,
|
|
65
|
-
"metadata": {},
|
|
66
|
-
"output_type": "execute_result"
|
|
67
|
-
}
|
|
68
|
-
],
|
|
69
|
-
"source": [
|
|
70
|
-
"sc_counts.iloc[:, :10].head()"
|
|
71
|
-
],
|
|
72
|
-
"metadata": {
|
|
73
|
-
"collapsed": false,
|
|
74
|
-
"ExecuteTime": {
|
|
75
|
-
"end_time": "2024-03-25T16:12:41.300170Z",
|
|
76
|
-
"start_time": "2024-03-25T16:12:41.284686Z"
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
"cell_type": "code",
|
|
82
|
-
"execution_count": 4,
|
|
83
|
-
"outputs": [
|
|
84
|
-
{
|
|
85
|
-
"data": {
|
|
86
|
-
"text/plain": "E2L4_GATGCTACAGGCACAA Monocytes\nL5_AACAACCAGGAACTAT Monocytes\nL5_TCCTTCTGTACTCCGG Monocytes\nL2_GCCCGAACACGTATAC Monocytes\nE2L2_ATGCATGTCACACCCT Monocytes\nName: 0, dtype: object"
|
|
87
|
-
},
|
|
88
|
-
"execution_count": 4,
|
|
89
|
-
"metadata": {},
|
|
90
|
-
"output_type": "execute_result"
|
|
91
|
-
}
|
|
92
|
-
],
|
|
93
|
-
"source": [
|
|
94
|
-
"annotations.head()"
|
|
95
|
-
],
|
|
96
|
-
"metadata": {
|
|
97
|
-
"collapsed": false,
|
|
98
|
-
"ExecuteTime": {
|
|
99
|
-
"end_time": "2024-03-25T16:12:41.982618Z",
|
|
100
|
-
"start_time": "2024-03-25T16:12:41.979126Z"
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"cell_type": "code",
|
|
106
|
-
"execution_count": 5,
|
|
107
|
-
"outputs": [
|
|
108
|
-
{
|
|
109
|
-
"data": {
|
|
110
|
-
"text/plain": " UBE2Q2P2 SSX9 CXorf67 EFCAB8 SPATA31B1P SDR16C6P GTPBP6 \npbmc_1 0.000000 0.0 0.118865 0.00000 0.0 0.0 57.280197 \\\npbmc_10 0.081115 0.0 0.086782 0.00000 0.0 0.0 72.275326 \npbmc_12 0.000000 0.0 0.188464 0.03157 0.0 0.0 50.997427 \n\n EFCAB12 A1BG A1CF \npbmc_1 0.252188 10.863071 0.0 \npbmc_10 0.095742 14.785649 0.0 \npbmc_12 0.100608 7.492537 0.0 ",
|
|
111
|
-
"text/html": "<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>UBE2Q2P2</th>\n <th>SSX9</th>\n <th>CXorf67</th>\n <th>EFCAB8</th>\n <th>SPATA31B1P</th>\n <th>SDR16C6P</th>\n <th>GTPBP6</th>\n <th>EFCAB12</th>\n <th>A1BG</th>\n <th>A1CF</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>pbmc_1</th>\n <td>0.000000</td>\n <td>0.0</td>\n <td>0.118865</td>\n <td>0.00000</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>57.280197</td>\n <td>0.252188</td>\n <td>10.863071</td>\n <td>0.0</td>\n </tr>\n <tr>\n <th>pbmc_10</th>\n <td>0.081115</td>\n <td>0.0</td>\n <td>0.086782</td>\n <td>0.00000</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>72.275326</td>\n <td>0.095742</td>\n <td>14.785649</td>\n <td>0.0</td>\n </tr>\n <tr>\n <th>pbmc_12</th>\n <td>0.000000</td>\n <td>0.0</td>\n <td>0.188464</td>\n <td>0.03157</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>50.997427</td>\n <td>0.100608</td>\n <td>7.492537</td>\n <td>0.0</td>\n </tr>\n </tbody>\n</table>\n</div>"
|
|
112
|
-
},
|
|
113
|
-
"execution_count": 5,
|
|
114
|
-
"metadata": {},
|
|
115
|
-
"output_type": "execute_result"
|
|
116
|
-
}
|
|
117
|
-
],
|
|
118
|
-
"source": [
|
|
119
|
-
"bulks.iloc[:, :10].head()"
|
|
120
|
-
],
|
|
121
|
-
"metadata": {
|
|
122
|
-
"collapsed": false,
|
|
123
|
-
"ExecuteTime": {
|
|
124
|
-
"end_time": "2024-03-25T16:12:43.131140Z",
|
|
125
|
-
"start_time": "2024-03-25T16:12:43.127235Z"
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
"cell_type": "markdown",
|
|
131
|
-
"metadata": {},
|
|
132
|
-
"source": [
|
|
133
|
-
"### Convert to AnnData object"
|
|
134
|
-
]
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
"cell_type": "code",
|
|
138
|
-
"execution_count": 7,
|
|
139
|
-
"outputs": [],
|
|
140
|
-
"source": [
|
|
141
|
-
"sc_adata = AnnData(sc_counts, obs=annotations.to_frame(name=\"cell_type\"))"
|
|
142
|
-
],
|
|
143
|
-
"metadata": {
|
|
144
|
-
"collapsed": false,
|
|
145
|
-
"ExecuteTime": {
|
|
146
|
-
"end_time": "2024-03-25T16:15:38.118620Z",
|
|
147
|
-
"start_time": "2024-03-25T16:15:38.098633Z"
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
"cell_type": "markdown",
|
|
153
|
-
"source": [
|
|
154
|
-
"# Single step Rectangle workflow"
|
|
155
|
-
],
|
|
156
|
-
"metadata": {
|
|
157
|
-
"collapsed": false
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
"metadata": {},
|
|
162
|
-
"cell_type": "markdown",
|
|
163
|
-
"source": "To deconvolute the bulk data in a single step, use the rectangle function. This function returns a tuple of the estimated cell type proportions and the signature result."
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
"cell_type": "code",
|
|
167
|
-
"outputs": [],
|
|
168
|
-
"source": [
|
|
169
|
-
"estimations, signature_result = rectangle.rectangle(sc_adata, bulks)"
|
|
170
|
-
],
|
|
171
|
-
"metadata": {
|
|
172
|
-
"collapsed": false
|
|
173
|
-
},
|
|
174
|
-
"execution_count": null
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
"cell_type": "code",
|
|
178
|
-
"outputs": [
|
|
179
|
-
{
|
|
180
|
-
"data": {
|
|
181
|
-
"text/plain": " B cells ILC Monocytes NK cells Plasma cells Platelet \npbmc_1 0.075919 0.001291 0.279064 0.046658 0.010834 0.008950 \\\npbmc_10 0.093986 0.003410 0.316445 0.033528 0.002279 0.036153 \npbmc_12 0.060533 0.017572 0.251589 0.114043 0.002038 0.027041 \n\n T cells CD4 conv T cells CD8 Tregs mDC pDC Unknown \npbmc_1 0.139600 0.268706 0.069930 0.017415 0.001971 0.079661 \npbmc_10 0.243435 0.146063 0.011599 0.032518 0.005273 0.075309 \npbmc_12 0.119488 0.325029 0.024586 0.027099 0.004422 0.026560 ",
|
|
182
|
-
"text/html": "<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>B cells</th>\n <th>ILC</th>\n <th>Monocytes</th>\n <th>NK cells</th>\n <th>Plasma cells</th>\n <th>Platelet</th>\n <th>T cells CD4 conv</th>\n <th>T cells CD8</th>\n <th>Tregs</th>\n <th>mDC</th>\n <th>pDC</th>\n <th>Unknown</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>pbmc_1</th>\n <td>0.075919</td>\n <td>0.001291</td>\n <td>0.279064</td>\n <td>0.046658</td>\n <td>0.010834</td>\n <td>0.008950</td>\n <td>0.139600</td>\n <td>0.268706</td>\n <td>0.069930</td>\n <td>0.017415</td>\n <td>0.001971</td>\n <td>0.079661</td>\n </tr>\n <tr>\n <th>pbmc_10</th>\n <td>0.093986</td>\n <td>0.003410</td>\n <td>0.316445</td>\n <td>0.033528</td>\n <td>0.002279</td>\n <td>0.036153</td>\n <td>0.243435</td>\n <td>0.146063</td>\n <td>0.011599</td>\n <td>0.032518</td>\n <td>0.005273</td>\n <td>0.075309</td>\n </tr>\n <tr>\n <th>pbmc_12</th>\n <td>0.060533</td>\n <td>0.017572</td>\n <td>0.251589</td>\n <td>0.114043</td>\n <td>0.002038</td>\n <td>0.027041</td>\n <td>0.119488</td>\n <td>0.325029</td>\n <td>0.024586</td>\n <td>0.027099</td>\n <td>0.004422</td>\n <td>0.026560</td>\n </tr>\n </tbody>\n</table>\n</div>"
|
|
183
|
-
},
|
|
184
|
-
"execution_count": 9,
|
|
185
|
-
"metadata": {},
|
|
186
|
-
"output_type": "execute_result"
|
|
187
|
-
}
|
|
188
|
-
],
|
|
189
|
-
"source": [
|
|
190
|
-
"estimations"
|
|
191
|
-
],
|
|
192
|
-
"metadata": {
|
|
193
|
-
"collapsed": false,
|
|
194
|
-
"ExecuteTime": {
|
|
195
|
-
"end_time": "2024-03-25T16:18:17.737030Z",
|
|
196
|
-
"start_time": "2024-03-25T16:18:17.731946Z"
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
"execution_count": 9
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
"cell_type": "markdown",
|
|
203
|
-
"source": "signature_result is a [`RectangleSignatureResult`](../generated/rectanglepy.pp.RectangleSignatureResult.rst) object.",
|
|
204
|
-
"metadata": {
|
|
205
|
-
"collapsed": false
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
"cell_type": "markdown",
|
|
210
|
-
"source": [
|
|
211
|
-
"# 2-step Rectangle workflow"
|
|
212
|
-
],
|
|
213
|
-
"metadata": {
|
|
214
|
-
"collapsed": false
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
"cell_type": "markdown",
|
|
219
|
-
"source": [
|
|
220
|
-
"Rectangle can also be run in two steps, first creating the signature and then deconvoluting the bulk data."
|
|
221
|
-
],
|
|
222
|
-
"metadata": {
|
|
223
|
-
"collapsed": false
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
"cell_type": "markdown",
|
|
228
|
-
"source": [
|
|
229
|
-
"## Create Signature result"
|
|
230
|
-
],
|
|
231
|
-
"metadata": {
|
|
232
|
-
"collapsed": false
|
|
233
|
-
}
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
"cell_type": "code",
|
|
237
|
-
"execution_count": null,
|
|
238
|
-
"outputs": [],
|
|
239
|
-
"source": [
|
|
240
|
-
"signature_result = rectangle.pp.build_rectangle_signatures(sc_adata, bulks=bulks)"
|
|
241
|
-
],
|
|
242
|
-
"metadata": {
|
|
243
|
-
"collapsed": false
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
"cell_type": "markdown",
|
|
248
|
-
"source": [
|
|
249
|
-
"This creates a [`RectangleSignatureResult`](../generated/rectanglepy.pp.RectangleSignatureResult.rst) object."
|
|
250
|
-
],
|
|
251
|
-
"metadata": {
|
|
252
|
-
"collapsed": false
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
"cell_type": "markdown",
|
|
257
|
-
"source": [
|
|
258
|
-
"## Deconvolute bulk data"
|
|
259
|
-
],
|
|
260
|
-
"metadata": {
|
|
261
|
-
"collapsed": false
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
"cell_type": "code",
|
|
266
|
-
"execution_count": null,
|
|
267
|
-
"outputs": [],
|
|
268
|
-
"source": [
|
|
269
|
-
"estimations = rectangle.tl.deconvolution(signature_result, bulks)"
|
|
270
|
-
],
|
|
271
|
-
"metadata": {
|
|
272
|
-
"collapsed": false
|
|
273
|
-
}
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
"cell_type": "markdown",
|
|
277
|
-
"source": [
|
|
278
|
-
"This returns a pandas DataFrame with the estimated cell type proportions."
|
|
279
|
-
],
|
|
280
|
-
"metadata": {
|
|
281
|
-
"collapsed": false
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
"cell_type": "code",
|
|
286
|
-
"outputs": [],
|
|
287
|
-
"source": [],
|
|
288
|
-
"metadata": {
|
|
289
|
-
"collapsed": false,
|
|
290
|
-
"ExecuteTime": {
|
|
291
|
-
"end_time": "2024-03-07T18:39:06.840457Z",
|
|
292
|
-
"start_time": "2024-03-07T18:39:06.838965Z"
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
"execution_count": 21
|
|
296
|
-
}
|
|
297
|
-
],
|
|
298
|
-
"metadata": {
|
|
299
|
-
"kernelspec": {
|
|
300
|
-
"display_name": "Python 3.9.12 ('squidpy39')",
|
|
301
|
-
"language": "python",
|
|
302
|
-
"name": "python3"
|
|
303
|
-
},
|
|
304
|
-
"language_info": {
|
|
305
|
-
"codemirror_mode": {
|
|
306
|
-
"name": "ipython",
|
|
307
|
-
"version": 3
|
|
308
|
-
},
|
|
309
|
-
"file_extension": ".py",
|
|
310
|
-
"mimetype": "text/x-python",
|
|
311
|
-
"name": "python",
|
|
312
|
-
"nbconvert_exporter": "python",
|
|
313
|
-
"pygments_lexer": "ipython3",
|
|
314
|
-
"version": "3.9.12"
|
|
315
|
-
},
|
|
316
|
-
"vscode": {
|
|
317
|
-
"interpreter": {
|
|
318
|
-
"hash": "ae6466e8d4f517858789b5c9e8f0ed238fb8964458a36305fca7bddc149e9c64"
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
"nbformat": 4,
|
|
323
|
-
"nbformat_minor": 4
|
|
324
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rectanglepy-0.5.0 → rectanglepy-0.5.1}/tests/data/quanTIseq_SimRNAseq_read_fractions_small.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|