KrishnaswamyLab / MELD

Quantifying experimental perturbations at single cell resolution
Other
105 stars 9 forks source link

Error using the VFC algorithm for clustering analysis #55

Open GabrielBaldissera opened 2 years ago

GabrielBaldissera commented 2 years ago

Hello!

I am trying to use the VFC to obtain clusters. I tried to adapt from the Jupyter notebook but I think I am missing something as I am getting an error.

My code:

G = gt.Graph(mir128_28H, knn=int(top_result['knn']), use_pygsp=True) #Obtain graph with best parameter
G.compute_fourier_basis()
VFC = meld.VertexFrequencyCluster(n_clusters=8, random_state=0)
VFC.fit_transform(G, sample_indicator=mir128_28H.obs['condition'], likelihood=mir128_28H.obs["MT_likelihood"])
VFC_clusters = VFC.predict(n_clusters=8)

My first error is for the VFC object I created:

AttributeError: 'VertexFrequencyCluster' object has no attribute 'random_state'

The second is for the VFC fit transform which I understand could be related to the sample IDs:

TypeError: unsupported operand type(s) for /: 'str' and 'int'

Any suggestions on how to do this?

Thank you for your help!

Best,

Gabriel

fouerghi commented 2 years ago

I am also running into this issue!

dburkhardt commented 1 year ago

If someone gets this issue again, can you please share the input you're passing to sample_indicator?

barbareyex commented 1 year ago

Hello!

I am trying to use the VFC to obtain clusters. I tried to adapt from the Jupyter notebook but I think I am missing something as I am getting an error.

My code:

G = gt.Graph(mir128_28H, knn=int(top_result['knn']), use_pygsp=True) #Obtain graph with best parameter
G.compute_fourier_basis()
VFC = meld.VertexFrequencyCluster(n_clusters=8, random_state=0)
VFC.fit_transform(G, sample_indicator=mir128_28H.obs['condition'], likelihood=mir128_28H.obs["MT_likelihood"])
VFC_clusters = VFC.predict(n_clusters=8)

My first error is for the VFC object I created:

AttributeError: 'VertexFrequencyCluster' object has no attribute 'random_state'

The second is for the VFC fit transform which I understand could be related to the sample IDs:

TypeError: unsupported operand type(s) for /: 'str' and 'int'

Any suggestions on how to do this?

Thank you for your help!

Best,

Gabriel

Hi Gabriel,

I also faced the first error and solved it by joining the VFC lines of code as: VFC = meld.VertexFrequencyCluster(n_clusters=8, random_state=0).fit_transform(G, sample_indicator=mir128_28H.obs['condition'], likelihood=mir128_28H.obs["MT_likelihood"])

The second error appears probably because in the sample_indicator you are including a list of strings. If you have two conditions, you could create another column in adata.obs with 0 values for one condition, and 1 for the others. That would solve the issue I think.