Skip to content

Commit

Permalink
Merge pull request #44 from bigbio/dev
Browse files Browse the repository at this point in the history
Multiple bugs fixed
  • Loading branch information
ypriverol authored Apr 24, 2024
2 parents 60d4bb3 + 08820da commit b12334d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion quantmsio/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.3"
__version__ = "0.0.4"
17 changes: 16 additions & 1 deletion quantmsio/core/diann_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,15 @@ def generate_feature_file(
feature_output_path,
):

sdrf = pd.read_csv(sdrf_path, sep="\t", usecols=["source name", "comment[data file]"])
sdrf = pd.read_csv(
sdrf_path, sep="\t", usecols=["source name", "comment[data file]", "comment[technical replicate]"]
)
samples = sdrf["source name"].unique()
mixed_map = dict(zip(samples, range(1, len(samples) + 1)))
sdrf["comment[data file]"] = sdrf["comment[data file]"].apply(lambda x: x.split(".")[0])
sdrf = sdrf.set_index(["comment[data file]"])
sdrf_map = sdrf.to_dict()["source name"]
tec_map = sdrf.to_dict()["comment[technical replicate]"]
report = report[report["intensity"] != 0]
report.loc[:, "fragment_ion"] = "NA"
report.loc[:, "isotope_label_type"] = "L"
Expand Down Expand Up @@ -515,6 +520,16 @@ def generate_feature_file(
)
# peptide_score_name = self._score_names["peptide_score"]
report.loc[:, "sample_accession"] = report["reference_file_name"].map(sdrf_map)
report.loc[:, "comment[technical replicate]"] = report["reference_file_name"].map(tec_map)
report.loc[:, "run"] = report[["sample_accession", "comment[technical replicate]", "fraction"]].swifter.apply(
lambda row: str(mixed_map[row["sample_accession"]])
+ "_"
+ str(row["comment[technical replicate]"])
+ "_"
+ str(row["fraction"]),
axis=1,
)
report.drop(["comment[technical replicate]"], axis=1, inplace=True)
schema = FeatureHandler()
feature = FeatureInMemory("LFQ", schema.schema)
feature._modifications = self._modifications
Expand Down
4 changes: 2 additions & 2 deletions quantmsio/core/feature_in_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,9 @@ def _merge_sdrf_to_msstats_in(self, sdrf_path, msstats_in):
["source name", "comment[technical replicate]", "comment[fraction identifier]"]
].swifter.apply(
lambda row: str(mixed_map[row["source name"]])
+ "-"
+ "_"
+ str(row["comment[technical replicate]"])
+ "-"
+ "_"
+ str(row["comment[fraction identifier]"]),
axis=1,
)
Expand Down

0 comments on commit b12334d

Please sign in to comment.