@@ -83,20 +83,20 @@ def tab1_undirected(tab1, final_prog_df, num_dis, edge_list, dis_list):
8383 " as follows:"
8484 )
8585 node_deg_mat = numpy_utils .node_deg_mat (edge_list , dis_list )
86- st .write (
87- pd .DataFrame (node_deg_mat , columns = dis_list ).set_index (pd .Index (dis_list ))
88- )
86+ node_deg_df = pd .DataFrame (node_deg_mat , columns = dis_list )
87+ st .write (node_deg_df .set_index (pd .Index (dis_list )))
8988
9089 tab1 .markdown ("* Calculate the adjacency matrix $A$" )
9190 with tab1 .expander ("How to calculate the adjacency matrix?" ):
9291 st .write ("$A = MM^{T} - D_n$" )
9392 col1 , col2 , col3 , col4 , col5 = st .columns ([1.5 , 6 , 6 , 1 , 6 ])
9493 col1 .write ("$A$ = " )
95- col2 .write (inc_mat .to_numpy ())
96- col3 .write (inc_mat .to_numpy ().transpose ())
97- col4 .write ("\-" )
94+ np_inc_mat = inc_mat .to_numpy ()
95+ col2 .write (np_inc_mat )
96+ col3 .write (np_inc_mat .transpose ())
97+ col4 .write ("$-$" )
9898 col5 .write (node_deg_mat )
99- inc_matT = np .matmul (inc_mat . to_numpy () , (inc_mat . to_numpy () .transpose ()))
99+ inc_matT = np .matmul (np_inc_mat , (np_inc_mat .transpose ()))
100100 adj_mat = inc_matT - node_deg_mat
101101
102102 tab1 .write ("$A$:" )
@@ -126,23 +126,23 @@ def tab1_undirected(tab1, final_prog_df, num_dis, edge_list, dis_list):
126126 st .markdown (
127127 r"""
128128 $$W(e_i) = \frac{C(e_i)}{C(e_i) + \sum_{e_j \in \mathcal{P}(e_i)}w_j C(e_j) + \sum_{e_k \in \mathcal{S}(e_i)}w_k C(e_k)},$$
129- """
129+ """ # noqa: E501
130130 )
131131 st .markdown (
132132 "where\n "
133- r"""$\mathcal{S}(e_i) = \{e_k \hspace{2pt} : \hspace{2pt} e_i \subset e_k\}.$"""
133+ r"""$\mathcal{S}(e_i) = \{e_k \hspace{2pt} : \hspace{2pt} e_i \subset e_k\}.$""" # noqa: E501
134134 )
135135 st .markdown (
136136 "For this example when we want to calculate the weight"
137137 " of a specific hyperedge $e_i$:\n "
138138 )
139139 st .markdown (
140- "* $\mathcal{P}(e_i)$ is"
140+ "* $\mathcal{P}(e_i)$ is" # noqa: W605
141141 " the power set of hyperedges for multimorbidity set"
142142 " $e_i$ (all subsets} disease sets)."
143143 )
144144 st .markdown (
145- "* $\mathcal{S}(e_i)$ is the super set of hyperedges for"
145+ "* $\mathcal{S}(e_i)$ is the super set of hyperedges for" # noqa: W605, E501
146146 " multimorbidity set $e_i$ (all disease sets containing"
147147 " $e_i$)."
148148 )
@@ -152,11 +152,11 @@ def tab1_undirected(tab1, final_prog_df, num_dis, edge_list, dis_list):
152152 " in the population\n "
153153 )
154154 st .markdown (
155- "* :red[$\sum_{e_j \in \mathcal{P}(e_i)} C(e_j)$] is the"
155+ "* :red[$\sum_{e_j \in \mathcal{P}(e_i)} C(e_j)$] is the" # noqa: W605, E501
156156 " sum of the power set prevalence"
157157 )
158158 st .markdown (
159- "* :red[$\sum_{e_k \in \mathcal{S}(e_i)} C(e_k)$] is the"
159+ "* :red[$\sum_{e_k \in \mathcal{S}(e_i)} C(e_k)$] is the" # noqa: W605, E501
160160 " sum of the super set prevalence"
161161 )
162162 st .markdown (
@@ -209,8 +209,8 @@ def tab1_undirected(tab1, final_prog_df, num_dis, edge_list, dis_list):
209209 " matrix $A = MW_{e}M^{T} - D_n$:"
210210 )
211211
212- MWe = np .matmul (inc_mat . to_numpy () , we_df .to_numpy ())
213- MWeMT = np .matmul (MWe , (inc_mat . to_numpy () .transpose ()))
212+ MWe = np .matmul (np_inc_mat , we_df .to_numpy ())
213+ MWeMT = np .matmul (MWe , (np_inc_mat .transpose ()))
214214 weighted_adj_mat = MWeMT - node_deg_mat
215215 np .fill_diagonal (weighted_adj_mat , 0.0001 )
216216 tab1 .write (weighted_adj_mat )
@@ -228,26 +228,26 @@ def tab1_undirected(tab1, final_prog_df, num_dis, edge_list, dis_list):
228228 "To calculate the Eigen values of the adjacency matrix"
229229 " we need to use the equation:"
230230 )
231- st .latex ("det(A - \lambda I) = 0" )
231+ st .latex ("det(A - \lambda I) = 0" ) # noqa: W605
232232 st .markdown (
233233 "Where $I$ is the equivalent order identity matrix"
234234 " (same shape as the adjacency matrix). Where the Eigen"
235235 " values are denoted as:"
236236 )
237- st .latex (f"\lambda_1, ..., \lambda_{ len (weighted_adj_mat )} " )
237+ st .latex (f"\lambda_1, ..., \lambda_{ len (weighted_adj_mat )} " ) # noqa: W605, E501
238238 st .markdown ("From the adjacency matrix above we get Eigen values:" )
239239 eigen_vals = linalg .eigvals (a = weighted_adj_mat )
240240 eigen_vals = np .real (np .round (eigen_vals , 3 ))
241241 for i , value in enumerate (eigen_vals ):
242- st .latex (f"\lambda_{ i } = { value } " )
242+ st .latex (f"\lambda_{ i } = { value } " ) # noqa: W605
243243
244244 maxvalue = max (eigen_vals )
245245 st .markdown (
246246 f"Then you take the maximum Eigen value { maxvalue } "
247247 " and use this to calculate the left Eigenvector. This is"
248- " done by substituting $\lambda$ into the equation below:"
248+ " done by substituting $\lambda$ into the equation below:" # noqa: W605, E501
249249 )
250- st .latex ("X^T A = X^T \lambda" )
250+ st .latex ("X^T A = X^T \lambda" ) # noqa: W605
251251 st .markdown ("Where $X$ is the vector:" )
252252 X = [* auc ][:num_dis ]
253253 st .write (pd .DataFrame (X ))
0 commit comments