Error message when using group_label
Hi,
When using the function mfx.plot_r2_barplot() with group_label, I get the following error message:
File ~/miniconda3/envs/scanpy/lib/python3.9/site-packages/mofax/plot_variance.py:237, in plot_r2_barplot(model, factors, view, groups_df, group_label, x, y, groupby, xtic klabels_size, linewidth, stacked, **kwargs) 195 def plot_r2_barplot( 196 model: mofa_model, 197 factors: Union[int, List[int], str, List[str]] = None, (...) 207 **kwargs, 208 ): 209 """ 210 Plot R2 values for the model 211 (...) 235 Plot a stacked barplot instead of a grouped barplot 236 """ --> 237 r2 = model.get_r2(factors=factors, groups_df=groups_df, group_label=group_label) 238 # Select a certain view if necessary 239 if view is not None:
File ~/miniconda3/envs/scanpy/lib/python3.9/site-packages/mofax/core.py:1141, in mofa_model.get_r2(self, factors, groups, views, groups_df, group_label) 1137 return self.get_variance_explained( 1138 factors=factors, groups=groups, views=views 1139 ) 1140 else: -> 1141 return self.calculate_variance_explained( 1142 factors=factors, groups=groups, views=views, group_label=group_label 1143 )
File ~/miniconda3/envs/scanpy/lib/python3.9/site-packages/mofax/core.py:1039, in mofa_model.calculate_variance_explained(self, factors, groups, views, group_label) 1033 for group in custom_groups: 1034 r2 = calculate_r2( 1035 Z=np.array(z_custom[group][factor_indices, :]), 1036 W=np.array(self.expectations["W"][view][factor_indices, :]), 1037 Y=np.array(data_view[group]), 1038 ) -> 1039 r2_df = r2_df.append( 1040 {"View": view, "Group": group, "R2": r2}, ignore_index=True 1041 ) 1042 return r2_df
File ~/miniconda3/envs/scanpy/lib/python3.9/site-packages/pandas/core/generic.py:6204, in NDFrame.getattr(self, name) 6197 if ( 6198 name not in self._internal_names_set 6199 and name not in self._metadata 6200 and name not in self._accessors 6201 and self._info_axis._can_hold_identifiers_and_holds_name(name) 6202 ): 6203 return self[name] -> 6204 return object.getattribute(self, name)
AttributeError: 'DataFrame' object has no attribute 'append'
I'm using pandas 1.5.3 and mofax 0.3.6.
Any idea how to solve this?
Thanks, Cristian
Hi,
I ran into a similar problem when using mofax.plot_r2_barplot(). In my case the r2 dataframe that was generated did not include factors when I used group_label; I added per_factor=True in all the calls and later I replaced the calls to append() with calls to pd.concat() to avoid all the warnings from pandas. See the fork at https://github.com/Leo-GG/mofax
Now updated to support the latest pandas!