BioTuring SpatialX Connector
Project description
BioTuring SpatialX Connector
Import
import os
import spatialx_connector
from spatialx_connector import SpatialXConnector
import warnings
warnings.filterwarnings("ignore")
Domain and Token
DOMAIN = "INPUT DOMAIN HERE"
TOKEN = "INPUT TOKEN HERE"
Explore Account
connector = SpatialXConnector(domain=DOMAIN, token=TOKEN)
spatialx_connector.format_print(connector.info)
spatialx_connector.format_print(connector.groups)
spatialx_connector.format_print(connector.s3)
spatialx_connector.format_print(connector.folders)
studies = connector.list_study(
group=spatialx_connector.DefaultGroup.PERSONAL_WORKSPACE.value,
species=spatialx_connector.Species.HUMAN,
)
spatialx_connector.format_print(studies)
study_details = connector.get_study_detail(studies[0]["study_id"])
spatialx_connector.format_print(study_details)
samples = connector.list_sample(studies[0]["study_id"])
spatialx_connector.format_print(samples)
sample_details = connector.get_sample_detail(samples[0]["sample_id"])
spatialx_connector.format_print(sample_details)
Uploading
uploading_results = connector.upload_file("/s3/colab/content/xenium/experiment.xenium")
spatialx_connector.format_print(uploading_results)
uploading_results = connector.upload_big_file("/s3/colab/content/xenium/morphology_mip.ome.tif", debug_mode=True)
spatialx_connector.format_print(uploading_results)
uploading_results = connector.upload_folder("/s3/colab/content/xenium", debug_mode=True)
spatialx_connector.format_print(uploading_results)
Submission
visium_submission_information = connector.parse_data_information(
"Visium_V2_Human_Colon_Cancer_P2",
spatialx_connector.Technologies.VISIUM,
os.path.join(
connector.s3["bioturingpublic"],
"SpatialX_datasets/Human_Colon_Cancer_P2/Visium_V2_Human_Colon_Cancer_P2"
)
)
spatialx_connector.format_print(visium_submission_information)
xenium_submission_information = connector.parse_data_information(
"Xenium_V1_Human_Colon_Cancer_P2_CRC_Add_on_FFPE",
spatialx_connector.Technologies.XENIUM,
os.path.join(
connector.s3["bioturingpublic"],
"SpatialX_datasets/Human_Colon_Cancer_P2/Xenium_V1_Human_Colon_Cancer_P2_CRC_Add_on_FFPE"
)
)
spatialx_connector.format_print(xenium_submission_information)
submission_results = connector.submit(
spatialx_connector.DefaultGroup.PERSONAL_WORKSPACE.value,
spatialx_connector.Species.HUMAN,
"10xgenomics",
"Human_Colon_Cancer_P2",
visium_submission_information
)
spatialx_connector.format_print(submission_results)
xenium_submission_results = connector.add_sample_data(
submission_results["study_id"],
submission_results["sample_id"],
xenium_submission_information,
)
submission_results["sample_data"].extend(xenium_submission_results["sample_data"])
spatialx_connector.format_print(submission_results)
Analysis
data_id = submission_results["sample_data"][-1]["data_id"]
data_id
Embeddings
response = connector.analysis.embeddings.pca(data_id=data_id, title="Connector - PCA")
spatialx_connector.format_print(response)
response = connector.analysis.embeddings.scvi(data_id=data_id, title="Connector - scVI", n_top_genes=2000)
spatialx_connector.format_print(response)
embeddings = connector.analysis.list_embedding(data_id)
spatialx_connector.format_print(embeddings)
response = connector.analysis.embeddings.umap(data_id=data_id, embedding_key=embeddings[0], title="Connector - UMAP")
spatialx_connector.format_print(response)
response = connector.analysis.embeddings.tsne(data_id=data_id, embedding_key=embeddings[0], title="Connector - tSNE")
spatialx_connector.format_print(response)
Clustering
response = connector.analysis.clustering.louvain(
data_id=data_id,
embedding_key=embeddings[0],
resolution=0.1,
title="Connector - Louvain",
)
spatialx_connector.format_print(response)
response = connector.analysis.clustering.kmeans(
data_id=data_id,
embedding_key=embeddings[0],
n_clusters=5,
title="Connector - k-means",
)
spatialx_connector.format_print(response)
Prediction
embeddings = connector.analysis.list_embedding(data_id)
spatialx_connector.format_print(embeddings)
metadata = connector.analysis.list_metadata(data_id)
spatialx_connector.format_print(metadata)
response = connector.analysis.prediction.metadata_reference(
data_id=data_id,
cluster_key=metadata[0],
species=spatialx_connector.Species.HUMAN,
title="Connector - Metadata Reference",
)
spatialx_connector.format_print(response)
Differential Expression
response = connector.analysis.de.differential_expression_genes(
data_id_1=data_id,
data_id_2=data_id,
group_1_indices=[i for i in range(10000)],
group_2_indices=[i for i in range(10000, 20000)],
title="Connector - DE genes",
)
spatialx_connector.format_print(response)
Spatial Analysis
response = connector.analysis.spatial_analysis.region_segmentation(
data_id=data_id,
radius=50,
mpp=0.2125,
resolution=0.5,
species=spatialx_connector.Species.HUMAN,
title="Connector - Region Segmentation",
)
spatialx_connector.format_print(response)
Convert data from Lens
!pip install bioturing_connector
LENS_SC_HOST: str = "LENS_SC_HOST"
LENS_SC_TOKEN: str = "LENS_SC_TOKEN"
lens_sc_studies = connector.list_lens_sc_studies(
host=LENS_SC_HOST, token=LENS_SC_TOKEN,
group=spatialx_connector.DefaultGroup.PERSONAL_WORKSPACE,
species=spatialx_connector.Species.HUMAN,
)
spatialx_connector.format_print(lens_sc_studies)
# Convert a study
connector.convert_data_from_lens(lens_sc_studies[0])
LENS_BULK_HOST: str = "LENS_BULK_HOST"
LENS_BULK_TOKEN: str = "LENS_BULK_TOKEN"
lens_bulk_studies = connector.list_lens_bulk_studies(
host=LENS_BULK_HOST, token=LENS_BULK_TOKEN,
group=spatialx_connector.DefaultGroup.PERSONAL_WORKSPACE,
species=spatialx_connector.Species.HUMAN,
)
spatialx_connector.format_print(lens_bulk_studies)
# Convert multiple studies
connector.convert_data_from_lens(lens_bulk_studies)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
spatialx_connector-0.1.2.tar.gz
(15.1 kB
view details)
Built Distribution
File details
Details for the file spatialx_connector-0.1.2.tar.gz
.
File metadata
- Download URL: spatialx_connector-0.1.2.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c425569655ca8acc4921598f85b15b03785786b2190c81ed505f23ebd67288e8 |
|
MD5 | 26fca933cbfca98446b9b055466508d1 |
|
BLAKE2b-256 | a5745d2324ea0befeaecd088f97b6a648f8eeb2d55985281368c3a16bf95ca20 |
File details
Details for the file spatialx_connector-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: spatialx_connector-0.1.2-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b1cfd03760eab520a24350306e69c1a25deddc04f431521e22db7bbb53c7b97 |
|
MD5 | 0c930d0b0f4024da9b76a6bd65aa86f8 |
|
BLAKE2b-256 | 17aabd965da9a4a5d3609189033a513fb9969c43303795a2cc4aa855b2d0ca43 |