Skip to content

Commit

Permalink
general code for mudata added
Browse files Browse the repository at this point in the history
  • Loading branch information
mari-ga committed Nov 7, 2023
1 parent 142eca8 commit a1e6078
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions bin/generate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,17 @@
adata.write("adata_with_donor_matching.h5ad")

if args.generate_mudata:
# write mudata_with_donor_matching.h5mu data
pass
rna_data = sc.read_10x_mtx(args.read_rna_mtx)
hto_data = sc.read_10x_mtx(args.read_hto_mtx, gex_only=False)
assignment_dir = os.path.join(args.assignment,
[filename for filename in os.listdir(args.assignment) if filename == "all_assignment_after_match.csv"][0])

assignment = pd.read_csv(assignment_dir, index_col = 0)
mudata = MuData({"rna": rna_data, "hto": hto_data })

mudata['rna'].obs = mudata['rna'].obs.merge(args.assignment, left_index=True, right_index=True, how='left')
mudata['rna'].obs.rename(columns={mudata['rna'].obs.columns[0]: 'donor'}, inplace=True)
mudata['rna'].obs.donor = mudata['rna'].obs.donor.fillna("negative")
mudata['rna'].obs.donor = mudata['rna'].obs.donor.astype(str)
mudata.update()
mudata.write("mudata_with_donor_matching.h5mu")

0 comments on commit a1e6078

Please sign in to comment.