to_sce#
- SingleCell.to_sce(sce_object_name, /, *, QC_column='passed_QC', assay='counts', empty_X=False)[source]#
Convert this SingleCell dataset to a SingleCellExperiment object in the R workspace of the ryp Python-R bridge.
Make sure to remove cells failing QC with sc.filter_obs(QC_column) first, or specify subset=True in qc(). Alternatively, to include cells failing QC in the SingleCellExperiment object, set QC_column to None.
varm, obsp, varp, and DataFrame keys of obsm will not be converted.
- Parameters:
sce_object_name: str
the name of the R variable to assign the SingleCellExperiment object to
QC_column: str | None
if not None, raise an error if this column is present in obs and not all cells pass QC
assay: str
the name of the slot within {sce_object_name}@assays@data to save X to
empty_X: bool
if True, allow converting SingleCell datasets with missing counts (i.e. where self.X is None), by using an empty, dummy matrix with no non-zero entries as the SingleCellExperiment object’s count matrix
- Return type:
None
Note
SingleCellExperiment objects do not support count matrices with more than 2,147,483,647 (INT32_MAX) non-zero elements. If your SingleCell dataset is larger than this, it cannot be converted!
Note
SingleCellExperiment requires the counts to be float64 and the indices of the count matrix to be int32. To avoid copying data when converting, consider converting the counts to float64 with sc.X = sc.X.astype(np.float64, copy=False) and the indices with sc.X.shrink_indices() (an in-place operation).
Note
In the special case where the counts are float64 or the indices of the count matrix are int32, the counts or indices will not be copied during the conversion to save memory. This means modifying the SinglecellExperiment object’s count matrix will also modify the original SingleCell dataset. If this behavior is undesirable, explicitly copy the dataset before converting with sc.copy().to_sce().