Skip to content

Commit

Permalink
compensation matrix reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ngreenwald committed Nov 24, 2021
1 parent 0dd399b commit db25d84
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions ark/mibi/rosetta_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import json

import numpy as np
import pandas as pd
Expand All @@ -11,6 +12,31 @@
from ark.utils.misc_utils import verify_same_elements


def transform_compensation_json(json_path, comp_mat_path):
"""Converts the JSON file from ionpath into a compensation matrix
Args:
json_path: path to json file
comp_mat_path: path to comp matrix
returns:
pd.DataTable: matrix with sources channels as rows and target channels as columns"""

with open(json_path) as f:
data = json.load(f)['Data']

comp_mat = pd.read_csv(comp_mat_path, index_col=0)

for i in range(len(data)):
current_data = data[i]
source = current_data['DonorMass']
target = current_data['RecipientMass']
val = current_data['Percent'] / 100
comp_mat.loc[source, str(target)] = val

comp_mat.to_csv(comp_mat_path)


def compensate_matrix_simple(raw_inputs, comp_coeffs):
"""Perform compensation on the raw data using the supplied compensation values
Expand Down

0 comments on commit db25d84

Please sign in to comment.