EmanuelGoncalves / crispy

Python module to analyse CRISPR-based libraries
BSD 3-Clause "New" or "Revised" License
10 stars 3 forks source link

AttributeError: 'CrispyGaussian' object has no attribute 'copy_x_train' #5

Open agiraldeztrujillo opened 10 months ago

agiraldeztrujillo commented 10 months ago

Hello! I'm trying to use crispy to make a CNV correction of my CRISPR/Cas9 KO screen data, but first I wanted to run the example script, mostly to get a feel for the package and check that everything works smoothly. When I reach this step:

bed_df = crispy.correct(n_sgrna=10) print(bed_df.head())

I find myself with this error:


AttributeError Traceback (most recent call last) /home/antonio_gt/TFM/BAGEL/Intento_2/PatuT_control/day7/bagel_script_PatuT_control_day7.ipynb Cell 17 line 1 ----> 1 bed_df_ex = crispy_ex.correct(n_sgrna=10) 2 print(bed_df_ex.head())

File ~/anaconda3/envs/mamba/envs/crispy/lib/python3.9/site-packages/crispy/CopyNumberCorrection.py:94, in Crispy.correct(self, x_features, y_feature, n_sgrna) 92 # - Fit Gaussian Process on segment fold-changes 93 self.gpr = CrispyGaussian(bed_df, n_sgrna=n_sgrna) ---> 94 self.gpr = self.gpr.fit(x=x_features, y=y_feature) 96 bed_df["gp_mean"] = self.gpr.predict(bed_df[x_features]) 98 # - Correct fold-change by subtracting the estimated mean

File ~/anaconda3/envs/mamba/envs/crispy/lib/python3.9/site-packages/crispy/CopyNumberCorrection.py:270, in CrispyGaussian.fit(self, x, y, train_idx) 267 x = self.bed_seg.query(f"sgRNA_ID >= {self.n_sgrna}")[x] 268 y = self.bed_seg.query(f"sgRNA_ID >= {self.n_sgrna}")[y] --> 270 return super().fit(x, y)

File ~/anaconda3/envs/mamba/envs/crispy/lib/python3.9/site-packages/sklearn/base.py:1145, in _fit_context..decorator..wrapper(estimator, *args, **kwargs) 1140 partial_fit_and_fitted = ( 1141 fit_method.name == "partial_fit" and _is_fitted(estimator) 1142 ) 1144 if not global_skip_validation and not partial_fit_and_fitted: -> 1145 estimator._validate_params() 1147 with config_context( ... --> 195 value = getattr(self, key) 196 if deep and hasattr(value, "get_params") and not isinstance(value, type): 197 deep_items = value.get_params().items()

AttributeError: 'CrispyGaussian' object has no attribute 'copy_x_train'

As I understand it, it seems the CrispyGaussian class is lacking on a way to read a 'copy_x_train' attribute. I'm still kind of new to Python, so I don't really know how to fix this issue. Could I request some assistance? I can give more info or data if necessary.

agiraldeztrujillo commented 10 months ago

Ok, so as a bit of a follow-up, I just went and tried with my own data, and now the error is a little bit different:

AttributeError Traceback (most recent call last) /home/antonio_gt/TFM/BAGEL/Intento_2/PatuT_control/day7/bagel_script_PatuT_control_day7.ipynb Cell 20 line 1 ----> 1 bed_df_ex = crispy_ex.correct(n_sgrna=10) 2 print(bed_df_ex.head())

File ~/anaconda3/envs/mamba/envs/crispy/lib/python3.9/site-packages/crispy/CopyNumberCorrection.py:94, in Crispy.correct(self, x_features, y_feature, n_sgrna) 92 # - Fit Gaussian Process on segment fold-changes 93 self.gpr = CrispyGaussian(bed_df, n_sgrna=n_sgrna) ---> 94 self.gpr = self.gpr.fit(x=x_features, y=y_feature) 96 bed_df["gp_mean"] = self.gpr.predict(bed_df[x_features]) 98 # - Correct fold-change by subtracting the estimated mean

File ~/anaconda3/envs/mamba/envs/crispy/lib/python3.9/site-packages/crispy/CopyNumberCorrection.py:270, in CrispyGaussian.fit(self, x, y, train_idx) 267 x = self.bed_seg.query(f"sgRNA_ID >= {self.n_sgrna}")[x] 268 y = self.bed_seg.query(f"sgRNA_ID >= {self.n_sgrna}")[y] --> 270 return super().fit(x, y)

File ~/anaconda3/envs/mamba/envs/crispy/lib/python3.9/site-packages/sklearn/base.py:1145, in _fit_context..decorator..wrapper(estimator, *args, **kwargs) 1140 partial_fit_and_fitted = ( 1141 fit_method.name == "partial_fit" and _is_fitted(estimator) 1142 ) 1144 if not global_skip_validation and not partial_fit_and_fitted: -> 1145 estimator._validate_params() 1147 with config_context( ... --> 195 value = getattr(self, key) 196 if deep and hasattr(value, "get_params") and not isinstance(value, type): 197 deep_items = value.get_params().items()

AttributeError: 'CrispyGaussian' object has no attribute 'bed_df'

EmanuelGoncalves commented 10 months ago

Can you check if bedtools are running fine for you?

agiraldeztrujillo commented 10 months ago

Yeah, bedtools seems to be working fine