Matrix

Matrix class

Main Matrix Class.

class diffupy.matrix.Matrix(mat=None, rows_labels=None, cols_labels=None, graph=None, quadratic=False, name='', init_value=None)[source]

Matrix class.

Initialize matrix.

Parameters
  • mat – matrix initialization

  • rows_labels

  • cols_labels – column labels

  • graph – graph

  • quadratic – quadratic

  • name – name

  • init_value – value to be initialized (int) or list of values from labels

validate_labels()[source]

Sanity function to check the dimensionality of the Matrix.

update_ix_mappings()[source]

Update the index-label mapping.

validate_labels_and_update_ix_mappings()[source]

Update function, called when the Matrix mutates, combining the two previous functionalities.

property cols_labels

Return a copy of Matrix Object.

property rows_labels_ix_mapping

Set row labels to ix.

property cols_labels_ix_mapping

Set column labels to ix.

property rows_idx_scores_mapping

Set mapping indexes to scores.

property cols_idx_scores_mapping

Set mapping indexes to scores.

get_row_from_label(label)[source]

Get row from labels.

set_row_from_label(label, x)[source]

Set row from label.

delete_row_from_label(label)[source]

Set row from label.

get_col_from_label(label)[source]

Get col from labels.

delete_col_from_label(label)[source]

Set col from label.

set_cell_from_labels(row_label, col_label, x)[source]

Set cell from labels.

get_cell_from_labels(row_label, col_label)[source]

Get cell from labels.

row_bind(rows=None, rows_labels=None, matrix=None)[source]

Return a copy of Matrix Object.

col_bind(cols=None, cols_labels=None, matrix=None)[source]

Return a copy of Matrix Object.

match_rows(reference_matrix)[source]

Match method to set rows labels as reference matrix.

match_cols(reference_matrix)[source]

Match method to set cols labels as reference matrix.

match_mat(reference_matrix, match_quadratic=None)[source]

Match method to set axis labels as reference matrix.

match_missing_rows(reference_labels, missing_fill=0)[source]

Match method to set missing rows labels from reference labels with the missing_fill value.

match_delete_rows(reference_labels)[source]

Match method to set missing rows labels from reference labels with the missing_fill value.

match_missing_cols(reference_labels, missing_fill)[source]

Match method to set missing cols labels from reference labels with the missing_fill value.

order_rows(reverse=True, col_ref_idx=None)[source]

Order matrix rows by cell values.

len_not_null()[source]

Get count of n cells not 0 in matrix.

binarize(null_value=- 1, threshold=0, positive_value=1)[source]

Get count of n cells not 0 in matrix.

to_dict(ordered=True)[source]

Export/convert matrix as a dictionary data structure.

as_pd_dataframe(ordered=True)[source]

Export matrix as a data frame using the headers (row_labels, cols_labels) of the Matrix class.

as_csv(path, index=True, ordered=True)[source]

Export matrix to csv file using the headers (row_labels, cols_labels) of the Matrix class.

to_nx_graph()[source]

Export matrix as a Graph using the headers (row_labels, cols_labels) of the Matrix class.

class diffupy.matrix.LaplacianMatrix(graph, normalized=False, node_argument='name', name='')[source]

Laplacian matrix class.

Initialize laplacian.