2分钟了解Anndata

一、什么是anndata?

python的一个库,专门用于处理、分析单细胞RNA测序数据或其他高维生物数据。
单细胞RNA测序分析工具scanpy处理对象就是anndata数据结构。

二、数据结构

表格式数据~dataframe
![[Pasted image 20231223153002.png]]在这里插入图片描述

组成部分

  • .X :np.array 基因表达矩阵【cell x gene】
  • .obs:pd.DataFrame 细胞的注释信息
  • .var:pd.DataFrame 基因的注释信息
  • .uns:dict 未排序的数据
  • .layers(层):存储其他数据层,如归一化后的数据、差异表达分析的结果
三、创建anndata对象
  • 使用scanpy创建
import scanpy as sc
adata = sc.AnnData(X=matrix,obs=obs)
  • 使用Anndata创建
import anndata as ad
adata = ad.AnnData(X=matrix,obs=obs)
Windows PowerShell 版权所有(C) Microsoft Corporation。保留所有权利。 安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows PS F:\pythonten\project> cl 用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.44.35209 版 版权所有(C) Microsoft Corporation。保留所有权利。 用法: cl [ 选项... ] 文件名... [ /link 链接选项... ] PS F:\pythonten\project> pip install mnnpy -i https://pypi.tuna.tsinghua.edu.cn/simple/ Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/ Collecting mnnpy Using cached https://pypi.tuna.tsinghua.edu.cn/packages/c2/6e/e8f963203e552d80a04adf80b19ecb248fa949b3db7a6fc935a2f49e8454/mnnpy-0.1.9.5.tar.gz (117 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Requirement already satisfied: numpy in f:\pythonten\python310\lib\site-packages (from mnnpy) (1.26.3) Requirement already satisfied: scipy in f:\pythonten\python310\lib\site-packages (from mnnpy) (1.12.0) Requirement already satisfied: anndata in f:\pythonten\python310\lib\site-packages (from mnnpy) (0.9.2) Requirement already satisfied: pandas in f:\pythonten\python310\lib\site-packages (from mnnpy) (2.2.0) Requirement already satisfied: numba in f:\pythonten\python310\lib\site-packages (from mnnpy) (0.58.1) Requirement already satisfied: h5py>=3 in f:\pythonten\python310\lib\site-packages (from anndata->mnnpy) (3.10.0) Requirement already satisfied: natsort in f:\pythonten\python310\lib\site-packages (from anndata->mnnpy) (8.4.0) Requirement already satisfied: packaging>=20 in f:\pythonten\python310\lib\site-packages (from anndata->mnnpy) (23.2) Requirement already satisfied: python-dateutil>=2.8.2 in f:\pythonten\python310\lib\site-packages (from pandas->mnnpy) (2.8.2) Requirement already satisfied: pytz>=2020.1 in f:\pythonten\python310\lib\site-packages (from pandas->mnnpy) (2023.3.post1) Requirement already satisfied: tzdata>=2022.7 in f:\pythonten\python310\lib\site-packages (from pandas->mnnpy) (2023.4) Requirement already satisfied: six>=1.5 in f:\pythonten\python310\lib\site-packages (from python-dateutil>=2.8.2->pandas->mnnpy) (1.16.0) Requirement already satisfied: llvmlite<0.42,>=0.41.0dev0 in f:\pythonten\python310\lib\site-packages (from numba->mnnpy) (0.41.1) Building wheels for collected packages: mnnpy Building wheel for mnnpy (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for mnnpy (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [73 lines of output] C:\Users\Lenovo\AppData\Local\Temp\pip-build-env-2jqu8z5o\overlay\Lib\site-packages\setuptools\dist.py:599: SetuptoolsDeprecationWarning: Invalid dash-separated key 'python-tag' in 'bdist_wheel' (setup.cfg), please use the underscore name 'python_tag' instead. !! ******************************************************************************** Usage of dash-separated 'python-tag' will not be supported in future versions. Please use the underscore name 'python_tag' instead. (Affected: mnnpy). By 2026-Mar-03, you need to update your project and remove deprecated calls or your builds will no longer be supported. See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details. ******************************************************************************** !! opt = self._enforce_underscore(opt, section) C:\Users\Lenovo\AppData\Local\Temp\pip-build-env-2jqu8z5o\overlay\Lib\site-packages\setuptools\dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated. !! ******************************************************************************** Please consider removing the following classifiers in favor of a SPDX license expression: License :: OSI Approved :: BSD License See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details. ******************************************************************************** !! self._finalize_license_expression() Building with c. running bdist_wheel running build running build_py file irlb.py (for module irlb) not found file mnn.py (for module mnn) not found file utils.py (for module utils) not found creating build\lib.win-amd64-cpython-310\mnnpy copying mnnpy\irlb.py -> build\lib.win-amd64-cpython-310\mnnpy copying mnnpy\mnn.py -> build\lib.win-amd64-cpython-310\mnnpy copying mnnpy\settings.py -> build\lib.win-amd64-cpython-310\mnnpy copying mnnpy\utils.py -> build\lib.win-amd64-cpython-310\mnnpy copying mnnpy\__init__.py -> build\lib.win-amd64-cpython-310\mnnpy file irlb.py (for module irlb) not found file mnn.py (for module mnn) not found file utils.py (for module utils) not found running build_ext building 'mnnpy._utils' extension creating build\temp.win-amd64-cpython-310\Release\mnnpy "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IF:\pythonten\python310\include -IF:\pythonten\python310 \Include "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\ATLMFC\include" "- IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0 .26100.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\cppwinrt" /Tcmnnpy/_utils.c /Fobuild\temp.win-amd64-cpython-310\Release\mnnpy\_utils.obj -O2 -ffast-math -march=native -fopenmp cl: 命令行 warning D9002 :忽略未知选项“-ffast-math” cl: 命令行 warning D9002 :忽略未知选项“-march=native” cl: 命令行 warning D9002 :忽略未知选项“-fopenmp” _utils.c mnnpy/_utils.c(2117): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据 mnnpy/_utils.c(2359): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据 mnnpy/_utils.c(2576): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据 mnnpy/_utils.c(16475): error C2105: “++”需要左值 mnnpy/_utils.c(16477): error C2105: “--”需要左值 mnnpy/_utils.c(16764): error C2105: “++”需要左值 mnnpy/_utils.c(16766): error C2105: “--”需要左值 mnnpy/_utils.c(17003): error C2105: “++”需要左值 mnnpy/_utils.c(17005): error C2105: “--”需要左值 mnnpy/_utils.c(17615): warning C4996: 'PyEval_InitThreads': deprecated in 3.9 mnnpy/_utils.c(17674): error C2039: "tp_print": 不是 "_typeobject" 的成员 F:\pythonten\python310\include\cpython/object.h(191): note: 参见“_typeobject”的声明 mnnpy/_utils.c(17679): error C2039: "tp_print": 不是 "_typeobject" 的成员 F:\pythonten\python310\include\cpython/object.h(191): note: 参见“_typeobject”的声明 mnnpy/_utils.c(17694): error C2039: "tp_print": 不是 "_typeobject" 的成员 F:\pythonten\python310\include\cpython/object.h(191): note: 参见“_typeobject”的声明 mnnpy/_utils.c(17707): error C2039: "tp_print": 不是 "_typeobject" 的成员 F:\pythonten\python310\include\cpython/object.h(191): note: 参见“_typeobject”的声明 mnnpy/_utils.c(19372): warning C4996: 'PyUnicode_FromUnicode': deprecated in 3.3 error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.44.35207\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for mnnpy Failed to build mnnpy ERROR: Failed to build installable wheels for some pyproject.toml based projects (mnnpy) PS F:\pythonten\project> pip install mnnpy Collecting mnnpy Using cached mnnpy-0.1.9.5.tar.gz (117 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Requirement already satisfied: numpy in f:\pythonten\python310\lib\site-packages (from mnnpy) (1.26.3) Requirement already satisfied: scipy in f:\pythonten\python310\lib\site-packages (from mnnpy) (1.12.0) Requirement already satisfied: anndata in f:\pythonten\python310\lib\site-packages (from mnnpy) (0.9.2) Requirement already satisfied: pandas in f:\pythonten\python310\lib\site-packages (from mnnpy) (2.2.0) Requirement already satisfied: numba in f:\pythonten\python310\lib\site-packages (from mnnpy) (0.58.1) Requirement already satisfied: h5py>=3 in f:\pythonten\python310\lib\site-packages (from anndata->mnnpy) (3.10.0) Requirement already satisfied: natsort in f:\pythonten\python310\lib\site-packages (from anndata->mnnpy) (8.4.0) Requirement already satisfied: packaging>=20 in f:\pythonten\python310\lib\site-packages (from anndata->mnnpy) (23.2) Requirement already satisfied: python-dateutil>=2.8.2 in f:\pythonten\python310\lib\site-packages (from pandas->mnnpy) (2.8.2) Requirement already satisfied: pytz>=2020.1 in f:\pythonten\python310\lib\site-packages (from pandas->mnnpy) (2023.3.post1) Requirement already satisfied: tzdata>=2022.7 in f:\pythonten\python310\lib\site-packages (from pandas->mnnpy) (2023.4) Requirement already satisfied: six>=1.5 in f:\pythonten\python310\lib\site-packages (from python-dateutil>=2.8.2->pandas->mnnpy) (1.16.0) Requirement already satisfied: llvmlite<0.42,>=0.41.0dev0 in f:\pythonten\python310\lib\site-packages (from numba->mnnpy) (0.41.1) Building wheels for collected packages: mnnpy Building wheel for mnnpy (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for mnnpy (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [73 lines of output] C:\Users\Lenovo\AppData\Local\Temp\pip-build-env-sra4z_m5\overlay\Lib\site-packages\setuptools\dist.py:599: SetuptoolsDeprecationWarning: Invalid dash-separated key 'python-tag' in 'bdist_wheel' (setup.cfg), please use the underscore name 'python_tag' instead. !! ******************************************************************************** Usage of dash-separated 'python-tag' will not be supported in future versions. Please use the underscore name 'python_tag' instead. (Affected: mnnpy). By 2026-Mar-03, you need to update your project and remove deprecated calls or your builds will no longer be supported. See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details. ******************************************************************************** !! opt = self._enforce_underscore(opt, section) C:\Users\Lenovo\AppData\Local\Temp\pip-build-env-sra4z_m5\overlay\Lib\site-packages\setuptools\dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated. !! ******************************************************************************** Please consider removing the following classifiers in favor of a SPDX license expression: License :: OSI Approved :: BSD License See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details. ******************************************************************************** !! self._finalize_license_expression() Building with c. running bdist_wheel running build running build_py file irlb.py (for module irlb) not found file mnn.py (for module mnn) not found file utils.py (for module utils) not found creating build\lib.win-amd64-cpython-310\mnnpy copying mnnpy\irlb.py -> build\lib.win-amd64-cpython-310\mnnpy copying mnnpy\mnn.py -> build\lib.win-amd64-cpython-310\mnnpy copying mnnpy\settings.py -> build\lib.win-amd64-cpython-310\mnnpy copying mnnpy\utils.py -> build\lib.win-amd64-cpython-310\mnnpy copying mnnpy\__init__.py -> build\lib.win-amd64-cpython-310\mnnpy file irlb.py (for module irlb) not found file mnn.py (for module mnn) not found file utils.py (for module utils) not found running build_ext building 'mnnpy._utils' extension creating build\temp.win-amd64-cpython-310\Release\mnnpy "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IF:\pythonten\python310\include -IF:\pythonten\python310 \Include "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\ATLMFC\include" "- IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0 .26100.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\cppwinrt" /Tcmnnpy/_utils.c /Fobuild\temp.win-amd64-cpython-310\Release\mnnpy\_utils.obj -O2 -ffast-math -march=native -fopenmp cl: 命令行 warning D9002 :忽略未知选项“-ffast-math” cl: 命令行 warning D9002 :忽略未知选项“-march=native” cl: 命令行 warning D9002 :忽略未知选项“-fopenmp” _utils.c mnnpy/_utils.c(2117): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据 mnnpy/_utils.c(2359): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据 mnnpy/_utils.c(2576): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据 mnnpy/_utils.c(16475): error C2105: “++”需要左值 mnnpy/_utils.c(16477): error C2105: “--”需要左值 mnnpy/_utils.c(16764): error C2105: “++”需要左值 mnnpy/_utils.c(16766): error C2105: “--”需要左值 mnnpy/_utils.c(17003): error C2105: “++”需要左值 mnnpy/_utils.c(17005): error C2105: “--”需要左值 mnnpy/_utils.c(17615): warning C4996: 'PyEval_InitThreads': deprecated in 3.9 mnnpy/_utils.c(17674): error C2039: "tp_print": 不是 "_typeobject" 的成员 F:\pythonten\python310\include\cpython/object.h(191): note: 参见“_typeobject”的声明 mnnpy/_utils.c(17679): error C2039: "tp_print": 不是 "_typeobject" 的成员 F:\pythonten\python310\include\cpython/object.h(191): note: 参见“_typeobject”的声明 mnnpy/_utils.c(17694): error C2039: "tp_print": 不是 "_typeobject" 的成员 F:\pythonten\python310\include\cpython/object.h(191): note: 参见“_typeobject”的声明 mnnpy/_utils.c(17707): error C2039: "tp_print": 不是 "_typeobject" 的成员 F:\pythonten\python310\include\cpython/object.h(191): note: 参见“_typeobject”的声明 mnnpy/_utils.c(19372): warning C4996: 'PyUnicode_FromUnicode': deprecated in 3.3 error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.44.35207\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for mnnpy Failed to build mnnpy ERROR: Failed to build installable wheels for some pyproject.toml based projects (mnnpy)
最新发布
06-08
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值