def test_setattr(self, metadata_data): # warnings.simplefilter("error") from flotilla import Study study = Study(metadata_data.copy()) study.pooled = 'asdf'
def test_setattr(self, metadata_data): # warnings.simplefilter("error") from flotilla import Study study = Study(metadata_data.copy()) study.pooled = 'asdf'
def study(self, metadata_data, metadata_kws, mapping_stats_data, mapping_stats_kws, expression_data, expression_kws, splicing_data, splicing_kws, gene_ontology_data): from flotilla import Study kwargs = {} metadata = metadata_data.copy() splicing = splicing_data.copy() expression = expression_data.copy() mapping_stats = mapping_stats_data.copy() gene_ontology = gene_ontology_data.copy() kw_pairs = (('metadata', metadata_kws), ('mapping_stats', mapping_stats_kws), ('expression', expression_kws), ('splicing', splicing_kws)) for data_type, kws in kw_pairs: for kw_name, kw_value in kws.iteritems(): kwargs['{}_{}'.format(data_type, kw_name)] = kw_value return Study(metadata, mapping_stats_data=mapping_stats, expression_data=expression, splicing_data=splicing, gene_ontology_data=gene_ontology, **kwargs)
def toy_study(self, example_data): from flotilla import Study return Study(sample_metadata=example_data.metadata, version='0.1.0', expression_data=example_data.expression, splicing_data=example_data.splicing, metadata_phenotype_col='celltype')
def test_init_pooled(self, metadata_data, metadata_kws, pooled): from flotilla import Study metadata = metadata_data.copy() kws = dict(('metadata_' + k, v) for k, v in metadata_kws.items()) metadata['pooled'] = metadata.index.isin(pooled) study = Study(metadata, **kws) npt.assert_array_equal(sorted(study.pooled), sorted(pooled))
def test_init_metdadata_kws(self, metadata_data, metadata_kws): # Also need to check for when these are NAs from flotilla import Study kws = dict(('metadata_' + k, v) for k, v in metadata_kws.items()) study = Study(metadata_data, **kws) pdt.assert_frame_equal(study.metadata.data, metadata_data) pdt.assert_equal(study.version, '0.1.0') npt.assert_equal(study.pooled, None)
def test_init_outlier(self, metadata_data, metadata_kws, outliers): from flotilla import Study metadata = metadata_data.copy() kws = dict(('metadata_' + k, v) for k, v in metadata_kws.items()) metadata['outlier'] = metadata.index.isin(outliers) study = Study(metadata, **kws) npt.assert_array_equal(study.metadata.data, metadata)
def test_init_splicing(self, metadata_data, metadata_kws, splicing_data, splicing_kws): from flotilla import Study metadata = metadata_data.copy() splicing = splicing_data.copy() kw_pairs = (('metadata', metadata_kws), ('splicing', splicing_kws)) kwargs = {} for name, kws in kw_pairs: for k, v in kws.items(): kwargs['{}_{}'.format(name, k)] = v study = Study(metadata, splicing_data=splicing, **kwargs) pdt.assert_array_equal(study.splicing.data_original, splicing_data)
def test_init_expression(self, metadata_data, metadata_kws, expression_data, expression_kws): from flotilla import Study metadata = metadata_data.copy() expression = expression_data.copy() kw_pairs = (('metadata', metadata_kws), ('expression', expression_kws)) kwargs = {} for name, kws in kw_pairs: for k, v in kws.items(): kwargs['{}_{}'.format(name, k)] = v study = Study(metadata, expression_data=expression, **kwargs) pdt.assert_array_equal(study.expression.data_original, expression_data)
def test_init_technical_outlier(self, metadata_data, metadata_kws, technical_outliers, mapping_stats_data, mapping_stats_kws): from flotilla import Study metadata = metadata_data.copy() kw_pairs = (('metadata', metadata_kws), ('mapping_stats', mapping_stats_kws)) kwargs = {} for name, kws in kw_pairs: for k, v in kws.items(): kwargs['{}_{}'.format(name, k)] = v study = Study(metadata, mapping_stats_data=mapping_stats_data, **kwargs) pdt.assert_numpy_array_equal(sorted(study.technical_outliers), sorted(technical_outliers))
def test_init_bad_pooled(self, metadata_data, metadata_kws, pooled): from flotilla import Study metadata = metadata_data.copy() kws = dict(('metadata_' + k, v) for k, v in metadata_kws.items()) metadata['pooled_asdf'] = metadata.index.isin(pooled) study = Study(metadata, **kws) true_pooled = None if study.metadata.pooled_col is not None: if study.metadata.pooled_col in study.metadata.data: try: true_pooled = study.metadata.data.index[ study.metadata.data[study.metadata.pooled_col].astype( bool)] except KeyError: true_pooled = None npt.assert_equal(study.pooled, true_pooled)
def test_init(self, metadata_data): from flotilla import Study metadata = metadata_data.copy() study = Study(metadata) metadata['outlier'] = False true_default_sample_subsets = list( sorted( list( set(study.metadata.sample_subsets.keys()).difference( set(study.default_sample_subset))))) true_default_sample_subsets.insert(0, study.default_sample_subset) pdt.assert_frame_equal(study.metadata.data, metadata) pdt.assert_equal(study.version, '0.1.0') pdt.assert_equal(study.pooled, None) pdt.assert_equal(study.technical_outliers, None) pdt.assert_equal(study.phenotype_col, study.metadata.phenotype_col) pdt.assert_equal(study.phenotype_order, study.metadata.phenotype_order) pdt.assert_equal(study.phenotype_to_color, study.metadata.phenotype_to_color) pdt.assert_equal(study.phenotype_to_marker, study.metadata.phenotype_to_marker) pdt.assert_series_equal(study.sample_id_to_phenotype, study.metadata.sample_id_to_phenotype) pdt.assert_series_equal(study.sample_id_to_color, study.metadata.sample_id_to_color) pdt.assert_array_equal(study.phenotype_transitions, study.metadata.phenotype_transitions) pdt.assert_array_equal(study.phenotype_color_ordered, study.metadata.phenotype_color_order) pdt.assert_equal(study.default_sample_subset, 'all_samples') pdt.assert_equal(study.default_feature_subset, 'variant') pdt.assert_array_equal(study.default_sample_subsets, true_default_sample_subsets) pdt.assert_dict_equal(study.default_feature_subsets, {})