-
Notifications
You must be signed in to change notification settings - Fork 1
Description
@gillichu @uym2 thanks for creating this fantastic tool! It would be helpful to have a python API so lightweight inference tasks can be easily run in a jupyter notebook. I suggest taking a pd.DataFrame/np.array character_matrix and optionally a nx.DiGraph topology as input and outputting a nxDiGraph since this will enable compatibility with TreeData.
character_matrix = pd.DataFrame(character_matrix)
tdata = td.TreeData(obs = cell_metadata, obms = {"characters":character_matrix})
# With TreeData
tdata.obst["tree"] = laml.run_laml(tdata.obsm["characters"],depth_key = "time")
# Without TreeData
tree = laml.run_laml(character_matrix,depth_key = "time")
The inferred branch lengths and characters for ancestral nodes can be represented as node attributes in the nx.DiGraph. I typically use tree.nodes["0"]["time"] to store node times and tree.nodes["0"]["characters"] to store characters. When LAML is used for branch length estimation you could also take an nx.DiGraph as input then return a copy with "time" and "characters" attributes added. The key where these values are stored (e.g. "time") could be modifies with a parameter such as depth_key.
Happy to go into more detail here if that would be helpful. The goal is to have a simple API that works with or without TreeData.