File tree Expand file tree Collapse file tree
src/control_methods/perfect_integration Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414print ("Reading input files" , flush = True )
1515adata = ad .read_h5ad (par ["input_unintegrated" ])
1616
17+ # make sure batch is string so we don't run into issues later on when subsetting
18+ # also make sure is_control is numeric
19+ adata .obs ["batch" ] = adata .obs ["batch" ].astype ("str" )
20+ adata .obs ["is_control" ] = adata .obs ["is_control" ].astype (int )
21+
1722print ("Extracting and splitting unintegrated data" , flush = True )
1823
1924# split 1
20- adata_split1 = adata [(adata .obs .is_control > 0 ) | (adata .obs .batch == 1 )]
25+ # reminder: is_control > 0 will include control samples.
26+ adata_split1 = adata [(adata .obs .is_control > 0 ) | (adata .obs .batch == "1" )]
2127integrated_split1 = adata_split1 .layers ["preprocessed" ]
2228
2329# split 2 == split 1 in this case
2430
31+ print (
32+ "Sanity check: verifying perfect integration have both control and non-control samples" ,
33+ flush = True ,
34+ )
35+ # Check that we have both control and non-control cells
36+ n_control = (adata_split1 .obs .is_control > 0 ).sum ()
37+ n_non_control = (adata_split1 .obs .is_control == 0 ).sum ()
38+
39+ assert n_non_control > 0 , (
40+ f"Split 1 should contain cells from non-control samples, but found { n_non_control } cells!"
41+ )
42+ assert n_control > 0 , (
43+ f"Split 1 should contain cells from control samples, but found { n_control } cells!"
44+ )
45+
46+
2547print ("Write output AnnData to file" , flush = True )
2648# split 1
2749output_split1 = ad .AnnData (
You can’t perform that action at this time.
0 commit comments