<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Working on new API
The clustergrammer_widget class is now being loaded into the Network class. The class and widget instance are saved in th Network instance, net. This allows us to load data, cluster, and finally produce a new widget instance using the widget method. The instance of the widget is saved in net and can be used to grab the data from the clustergram as a Pandas DataFrame using the widget_df method. The exported DataFrame will reflect any filtering or imported categories that were added on the front end.
In these examples, we will filter the matrix using the brush crop tool, export the filtered matrix as a DataFrame, and finally visualize this as a new clustergram widget.
Step1:  Make widget using new API
Step2:  Above, we have filtered the matrix to a region of interest using the brush cropping tool. Below we will get export this region of interest, defined on the front end, to a DataFrame, df_genes. This demonstrates the two-way communication capabilities of widgets.
Step3:  Above, we made a new widget visualizing this region of interest. 
Generate random DataFrame
Here we will genrate a DataFrame with random data and visualize it using the widget.
Step4:  Above, we selected a region of interest using the front-end brush crop tool and export to DataFrame, df_random. Below we will visualize it using a new widget.
<ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
from clustergrammer_widget import *
net = Network(clustergrammer_widget)
Explanation: Working on new API
The clustergrammer_widget class is now being loaded into the Network class. The class and widget instance are saved in th Network instance, net. This allows us to load data, cluster, and finally produce a new widget instance using the widget method. The instance of the widget is saved in net and can be used to grab the data from the clustergram as a Pandas DataFrame using the widget_df method. The exported DataFrame will reflect any filtering or imported categories that were added on the front end.
In these examples, we will filter the matrix using the brush crop tool, export the filtered matrix as a DataFrame, and finally visualize this as a new clustergram widget.
End of explanation
net.load_file('rc_two_cats.txt')
net.cluster()
net.widget()
Explanation: Make widget using new API
End of explanation
df_genes = net.widget_df()
df_genes.shape
net.load_df(df_genes)
net.cluster()
net.widget()
Explanation: Above, we have filtered the matrix to a region of interest using the brush cropping tool. Below we will get export this region of interest, defined on the front end, to a DataFrame, df_genes. This demonstrates the two-way communication capabilities of widgets.
End of explanation
# generate random matrix
num_rows = 500
num_cols = 10
np.random.seed(seed=100)
mat = np.random.rand(num_rows, num_cols)
# make row and col labels
rows = range(num_rows)
cols = range(num_cols)
rows = [str(i) for i in rows]
cols = [str(i) for i in cols]
# make dataframe 
df = pd.DataFrame(data=mat, columns=cols, index=rows)
net.load_df(df)
net.cluster()
net.widget()
Explanation: Above, we made a new widget visualizing this region of interest. 
Generate random DataFrame
Here we will genrate a DataFrame with random data and visualize it using the widget.
End of explanation
df_random = net.widget_df()
df_random.shape
net.load_df(df_random)
net.cluster()
net.widget()
Explanation: Above, we selected a region of interest using the front-end brush crop tool and export to DataFrame, df_random. Below we will visualize it using a new widget.
End of explanation
<END_TASK>