def test_rm_sparse_samples(self, stool_biom): otu_inst = Otu(stool_biom) rm_samples_otu = otu_inst.rm_sparse_samples() assert otu_inst.otu_data.shape[0] == rm_samples_otu.otu_data.shape[0] assert otu_inst.otu_data.shape[1] > rm_samples_otu.otu_data.shape[1] assert otu_inst.otu_data.shape[1] - rm_samples_otu.otu_data.shape[ 1] == 1 norm_otu = otu_inst.normalize() with pytest.raises(ValueError): norm_otu.rm_sparse_samples()
def test_normalize(self, stool_biom): otu_inst = Otu(stool_biom) sample_norm = otu_inst.normalize() assert (otu_inst.otu_data.to_dataframe().sum(axis=0) > 1).all() assert np.isclose(sample_norm.otu_data.to_dataframe().sum(axis=0), 1.0).all() assert sample_norm.is_norm(axis="sample") obs_norm = otu_inst.normalize(axis="observation") assert (otu_inst.otu_data.to_dataframe().sum(axis=1) > 1).all() assert obs_norm.is_norm(axis="observation") assert np.isclose(obs_norm.otu_data.to_dataframe().sum(axis=1), 1.0).all() with pytest.raises(ValueError): otu_inst.normalize(method="random_method") with pytest.raises(NotImplementedError): otu_inst.normalize(method="css") with pytest.raises(NotImplementedError): otu_inst.normalize(method="rarefy")