postprocess_mnnpy

besca.tl.bcor.postprocess_mnnpy(adata, bdata)[source]

postprocessing to generate a newly functional AnnData object

After running mnnpy_mnncorrect we obtain ann AnnData object bdata. Since mnn_correct automatically truncates all the genes contained in .raw to contain only the highly variable genes this function creates a new AnnData object that contains .X from bdata but .raw from AnnData (which still contains all the genes, not only the highly variable ones).

Before creation of the new AnnData object the matrices are sorted according to cellbarcode so that we ensure the labelings are correct.

Parameters:
  • adata – the uncorrected AnnData object

  • bdata – the batch correted AnnData object

Returns:

AnnData object with adata.X containing the corrected values and .raw all of the original values

Return type:

AnnData