Giter Site home page Giter Site logo

compass's Introduction

compass 🧭

Vector representations of gene co-expression in single cell RNAseq.

Install:

python3 -m venv cenv
python3 setup.py install

Loading scanpy datasets into Compass.

from compass.data import Context, CompassDataset
context = Context.build(adata)
dataset = CompassDataset(context)

Training gene vectors.

from compass.model import CompassTrainer
cmps = CompassTrainer(dataset,output_file="genes.vec", batch_size=200)
cmps.train(10) # run for 10 iterations

Loading results.

from compass.embedding import GeneEmbedding, CellEmbedding
gembed = GeneEmbedding("genes.vec", context)
cembed = CellEmbedding(context, gembed)

Compute gene similarities.

gembed.compute_similarities("CD8A")

Clustering gene vectors.

gene_clusters = gembed.cluster()

Build gene t-SNE embedding and label some genes.

gembed.plot(gene_clusters,labels=["C1QC","C1QA","TYROBP"])

Find most representative genes for each cluster based on cosine distance.

cluster_definitions = gembed.cluster_definitions(gene_clusters)

Pandas data frame of most representative genes for each cluster.

gene_df = gembed.cluster_definitions_as_df(cluster_definitions,top_n=10)

Relabel cluster in results.

gembed.relabel_cluster(cluster_definitions, gene_clusters, 6, "Cell Cycle")

Generate an average vector for a set of genes.

cd8tcellvec = gembed.generate_vector(["CD8A","CD8B","CD3D","CD3E","CD3G"])

Plot a cosine similarity matrix for a set of genes.

gembed.plot_similarity_matrix(["CD8A","CD8B","CD3D","CD3E","CD3G"], png="cd8_matrix.png")

Plot a networkx graph of similarities between a set of genes.

plot_similarity_network(["CD8A","CD8B","CD3D","CD3E","CD3G"], png="cd8_graph.png"

Build cell t-SNE embedding with cell type labels.

tsne_embedding = cembed.plot(column="cell_type")

Reuse t-SNE embedding and plot another label.

cembed.plot(column="batch_label",pcs=tsne_embedding)

Find K cell clusters.

clusters = cembed.cluster(k=6)

Locally batch correct on clusters using column as batch label.

cembed.batch_correct(column="batch_label",clusters=clusters)

Regenerate corrected t-SNE

corrected_tsne_embedding = cembed.plot(column="batchlb")

Plot cosine distance for each cell to a given vector.

cembed.plot_distance(cd8tcellvec,png="highlightcd8cells.png")

compass's People

Contributors

nceglia avatar

Watchers

 avatar

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.