Giter VIP home page Giter VIP logo

dbsimilarity's Introduction

DBsimilarity

DBsimilarity is a method proposed in a scientific paper to help natural product researchers analyze chemical data obtained from databases. This method involves organizing structural databases into similarity networks to represent the chemical space of a given organism or biological system. The method includes various steps such as converting .sdf files into .csv files, adding chemoinformatics data, constructing a custom database for rapid dereplication of MS data on MZMine, constructing a candidate list of compounds for rapid dereplication of 2D NMR data on NMRfilter, calculating similarities between compounds, and convert this square matrix into a network type of file. Cytoscape is suggested as an ideal platform for visualizing similarity networks, and Jupyter Notebooks are recommended for their readability to assist users in developing valuable programming skills. The ultimate goal of this method is to help researchers better understand the rich information available from a list of compounds found in a specimen.

dbsimilarity's People

Contributors

ricardomborges avatar

Stargazers

Kozo Nishida avatar

Watchers

Kozo Nishida avatar James Cloos avatar  avatar

dbsimilarity's Issues

Optimisations and thoughts

I noticed in the notebook tutorials mention that calculating the similarity takes time and have a suggestion for how this could be sped up, starting with a df, my example uses Tanimoto similarity rather than DICE but the idea is the same. Also this is split into batches to avoid using too much memory as I ran it with graphs containing ~50,000 compounds but on smaller datasets the batching may not be needed:

def get_graph_data(df_with_fingerprints: pd.DataFrame, out_file: str, batchno: int, batchsize: int = 1000):
    # Calculate Tanimoto similarity for a given batch
    # Need to batch this to avoid OOMing. Each batch will get smaller
    sources, targets, similarities = [], [], []
    all_fingerprints = df_with_fingerprints['morgan_fingerprint'].values.tolist()
    for i in tqdm(range(batchsize)): # Use tqdm to estimate time
        batch_i = i + (batchsize * batchno)
        if batch_i <= (len(all_fingerprints) - 1):
            row = df_with_fingerprints.index[batch_i]
            fingerprint_1 = df_with_fingerprints.at[row, 'morgan_fingerprint']
            source_inchi_simp = df_with_fingerprints.at[row, COMPOUND_ID_COL]
            sims = DataStructs.BulkTanimotoSimilarity(fingerprint_1, all_fingerprints[batch_i + 1:])
            # collect the ids and values
            for m in range(len(sims)):
                target_row = df_with_fingerprints.index[batch_i + 1 + m]
                sources.append(source_inchi_simp)
                targets.append(df_with_fingerprints.at[target_row, COMPOUND_ID_COL])
                similarities.append(sims[m])
    if len(sources) > 0:
        simTable = pd.DataFrame(data={'SOURCE': sources, 'TARGET': targets, 'SIMILARITY': similarities})
        simTable = simTable.reset_index(drop=True)
        simTable.to_csv(out_file + str(batchno) + '.csv')
    else:
        print(f'No data for batch number: {batchno}')

PandasTools.AddMoleculeColumnToFrame(df, 'SMILES', 'Molecule', includeFingerprints=True)
# Produce a hashed Morgan fingerprint for each molecule
df['morgan_fingerprint'] = df['Molecule'].apply(lambda x: GetMorganFingerprintAsBitVect(x, 2)) #Use apply here for better readability
for i in range(number_of_batches):
    get_graph_data(df, os.path.join(graph_data_folder, 'all_graph_data'), i)

I also had a few other thoughts that would be good to get some insight into:

  1. What is the motivation for using Dice similarity rather than Tanimoto?
  2. There is a line where after making the simTable, you make a matrix with stack; but in this line you also use corr(). This seems unnecessary as you've already calculated the pairwise similarity between compounds which is stored in a single column, and as far as I understand corr() calculates the correlation between pairs of columns so it's not clear to me what this is doing
  3. As far as I understand, the methods you propose identify similarities between compounds in distinct databases and you get a metric that compares individual pairs of compounds. I am interested in whether you have any methods for quantifying how similar/related a single compound is to another dataset of compounds, and more generally quantifying how related one dataset of compounds is to another dataset of compounds
  4. Given that you're working with graphs, I wonder if there are any graph analysis/learning techniques you could leverage the knowledge contained in the graphs in order to do some predictions e.g. which compounds are likely to be found in which species or which compounds are likely to have a particular bioactivity etc...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.