Reading through this t-sne blogpost and I'm a little unclear on how i'd use either of these algorithms here for my goals. i get it'd cluster my samples based on similarity in terms of first and second principal components/t-SNEs, but what could i then use identify structural or sequence patterns within each cluster? please let me know if I'm missing something - thanks!

I'm also curious as to how I would apply PCA or t-SNE on my data considering its non-numerical nature. I was thinking of applying one-hot encoding, but is there a generally more suggested approach? I've attached a screenshot of a few of my dataset rows for context (for the sake of having the table fit, I chose rows with simpler structures/zero MFE values, but most rows have complex structures and non-zero MFE values). Thanks.

enter image description here

This is based on my previous post:

I have a bunch of RNA sequences (and their optimal secondary structures) and their corresponding energy values (measured by mean free energy) and I'm trying to find a way to identify features (patterns in their structures or sequences) common between samples of similar energy values. the overall goal is to try and identify sequence or structural elements in the RNA samples that tend to correlate with low mean free energy values. would be grateful if anyone could recommend me algorithms to look into using - I'm assuming this would be an unsupervised learning project and I only have experience with supervised stuff, but I'm looking into PCA right now and not sure if that'd be useful. should I be looking into something else?

Intuitively I'm imagining it as like a clustering + feature extraction problem where I have a bunch of dots, each representing an RNA sample, and then the axis represents energy so the dots could be clustered in energy value similarity and then within each energy value cluster patterns/relationships could be found between the sequences and structures of the samples. but not sure if an ML algo exists to handle this and PCA seems like not what I'm looking for because the axes would be principal components and not energy...


1 Answer 1


I'd recommend PCA, tSNE the PCA (first)+ tSNE (second).

The sequence data - one hot key encoding is a good idea.

import pandas as pd
datadict = {'UTR':[.....],'Sequence':['AGAA','ACAG' ...], 'Optimal Secondary Structure':[....]}
df = pd.DataFrame(datadict)
df_onehot = pd.get_dummies(df['Sequence'])
df = pd.concat([df, df_onehot], axis=1)     # add the one hot encoded column to master dataframe
df.drop(...) # remove the original 'Sequence' column

The other issue is vectorising the "dots". This is really a separate question, here's what I'd do ...

For optimal secondary structure, maybe simply count the dots?

count = df_series.str.count(".")

This only works on a series so you'll need to do something like df_list = df['Dots column'].to_list() and then df_series = pd.Series(df_list). Finally the count will need to be concat back onto the df and the original Dots deleted.

The thing I'm not clear about is your 'instances' that could be 'UTR_info' thats the stuff you are calling you data or "features".

  • 1
    $\begingroup$ Got it, but how does pca and tsne get me closer to actually identifying structural/sequence patterns present in the created clusters? $\endgroup$
    – joshua213p
    Aug 9, 2023 at 23:48
  • $\begingroup$ Thanks. You can now upvote BTW. This is about the fundamental design of your experiment. If post another question I'll sketch an outline about what unsupervised learning achieves. I don't exactly know your project aims (I can guess) but I know what unsupervised learning delivers. $\endgroup$
    – M__
    Aug 9, 2023 at 23:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.