vuecore.wgcna module#

vuecore.wgcna.get_heatmap(df, colorscale=None, color_missing=True)[source]#

This function plots a simple Plotly heatmap.

Parameters:
  • df – pandas dataframe containing experimental data, with samples/subjects as rows and features as columns.

  • colorscale (list[list]) – heatmap colorscale (e.g. [[0,’#67a9cf’],[0.5,’#f7f7f7’],[1,’#ef8a62’]]). If colorscale is not defined, will take [[0, ‘rgb(255,255,255)’], [1, ‘rgb(255,51,0)’]] as default.

  • color_missing (bool) – if set to True, plots missing values as grey in the heatmap.

Returns:

Plotly object figure.

vuecore.wgcna.get_module_color_annotation(map_list, col_annotation=False, row_annotation=False, bygene=False, module_colors=[], dendrogram=[])[source]#

This function takes a list of values, converts them into colors, and creates a new plotly object to be used as an annotation. Options module_colors and dendrogram only apply when map_list is a list of experimental features used in module eigenegenes calculation.

Parameters:
  • map_list (list) – dendrogram leaf labels.

  • col_annotation (bool) – if True, adds color annotations as a row.

  • row_annotation (bool) – if True, adds color annotations as a column.

  • bygene (bool) – determines wether annotation colors have to be reordered to match dendrogram leaf labels.

  • module_colors (list) – dendrogram leaf module color.

  • dendrogram (dict) – dendrogram represented as a plotly object figure.

Returns:

Plotly object figure.

Note

map_list and module_colors must have the same length.

vuecore.wgcna.plot_complex_dendrogram(dendro_df, subplot_df, title, dendro_labels=[], distfun='euclidean', linkagefun='average', hang=0.04, subplot='module colors', subplot_colorscale=[], color_missingvals=True, row_annotation=False, col_annotation=False, width=1000, height=800)[source]#

This function plots a dendrogram with a subplot below that can be a heatmap (annotated or not) or module colors.

Parameters:
  • dendro_df – pandas dataframe containing data used to generate dendrogram, columns will result in dendrogram leaves.

  • subplot_df – pandas dataframe containing data used to generate plot below dendrogram.

  • title (str) – the title of the figure.

  • dendro_labels (list) – list of strings for dendrogram leaf nodes labels.

  • distfun (str) – distance measure to be used (‘euclidean‘, ‘maximum‘, ‘manhattan‘, ‘canberra‘, ‘binary‘, ‘minkowski‘ or ‘jaccard‘).

  • linkagefun (str) – hierarchical/agglomeration method to be used (‘single‘, ‘complete‘, ‘average‘, ‘weighted‘, ‘centroid‘, ‘median‘ or ‘ward‘).

  • hang (float) – height at which the dendrogram leaves should be placed.

  • subplot (str) – type of plot to be shown below the dendrogram (´module colors´ or ´heatmap´).

  • subplot_colorscale (list) – colorscale to be used in the subplot.

  • color_missingvals (bool) – if set to True, plots missing values as grey in the heatmap.

  • row_annotation (bool) – if True, adds a color-coded column at the left of the heatmap.

  • col_annotation (bool) – if True, adds a color-coded row at the bottom of the heatmap.

  • width (int) – the width of the figure.

  • height (int) – the height of the figure.

Returns:

Plotly object figure.

vuecore.wgcna.plot_dendrogram_guidelines(Z_tree, dendrogram)[source]#

This function takes a dendrogram tree dictionary and its plotly object and creates shapes to be plotted as vertical dashed lines in the dendrogram.

Parameters:
  • Z_tree (dict) – dictionary of data structures computed to render the dendrogram. Keys: ‘icoords’, ‘dcoords’, ‘ivl’ and ‘leaves’.

  • dendrogram – dendrogram represented as a plotly object figure.

Returns:

List of dictionaries.

vuecore.wgcna.plot_intramodular_correlation(MM, FS, feature_module_df, title, width=1000, height=800)[source]#

This function uses the Feature significance and Module Membership measures, and plots a multi-scatter plot of all modules against all clinical traits.

Parameters:
  • MM – pandas dataframe with module membership data

  • FS – pandas dataframe with feature significance data

  • feature_module_df – pandas DataFrame of experimental features and module colors (use mode=’dataframe’ in get_FeaturesPerModule)

  • title (str) – plot title

  • width (int) – plot width

  • height (int) – plot height

Returns:

Plotly object figure.

Example:

plot = plot_intramodular_correlation(MM, FS, feature_module_df, title='Plot', width=1000, height=800):

Note

There is a limit in the number of subplots one can make in Plotly. This function limits the number of modules shown to 5.

vuecore.wgcna.plot_labeled_heatmap(df, textmatrix, title, colorscale=[[0, 'rgb(0,255,0)'], [0.5, 'rgb(255,255,255)'], [1, 'rgb(255,0,0)']], width=1200, height=800, row_annotation=False, col_annotation=False)[source]#

This function plots a simple Plotly heatmap with column and/or row annotations and heatmap annotations.

Parameters:
  • df – pandas dataframe containing data to be plotted in the heatmap.

  • textmatrix – pandas dataframe with heatmap annotations as values.

  • title (str) – the title of the figure.

  • colorscale (list[list]) – heatmap colorscale (e.g. [[0,’rgb(0,255,0)’],[0.5,’rgb(255,255,255)’],[1,’rgb(255,0,0)’]])

  • width (int) – the width of the figure.

  • height (int) – the height of the figure.

  • row_annotation (bool) – if True, adds a color-coded column at the left of the heatmap.

  • col_annotation (bool) – if True, adds a color-coded row at the bottom of the heatmap.

Returns:

Plotly object figure.