GithubHelp home page GithubHelp logo

yanwu2014 / swne Goto Github PK

View Code? Open in Web Editor NEW
102.0 5.0 20.0 216.25 MB

Similarity Weighted Nonnegative Embedding (SWNE), a method for visualizing high dimensional datasets

License: BSD 3-Clause "New" or "Revised" License

R 94.25% C++ 5.75%
single-cell-rna-seq single-cell-analysis data-visualization dimensionality-reduction nonnegative-matrix-factorization bioinformatics single-cell-genomics statistical-methods single-cell-atac-seq

swne's People

Contributors

kant avatar tomkellygenetics avatar yanwu2014 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

swne's Issues

installation error

hello, recently I failed to install the swne package on the linux server. Thus can you supply it using offline form ".tar.gz"??? In this way I can use "R CMD INSTALL" to install it. Thanks.

Error during execution of "Gene Expression Quickstart with Seurat"

I am attempting to run the example code after an installation of the swne package on a new machine but am getting the following error:
Error in requireNamespace(Seurat, quietly = T) : object 'Seurat' not found

The error occurs on the last line of the following code:

library(Seurat)
library(swne)
## Load data
obj <- readRDS("~/Downloads/pbmc3k_seurat.Robj")
## Get clusters
clusters <- obj@ident; names(clusters) <- [email protected];
## Build SNN
obj <- BuildSNN(obj, dims.use = 1:20, k.param = 20, prune.SNN = 1/20)
## Run SWNE
genes.embed <- c("MS4A1", "GNLY", "CD3E", "CD14",
                 "FCER1A", "FCGR3A", "LYZ", "PPBP", "CD8A")
swne.embedding <- RunSWNE(obj, k = 10, genes.embed = genes.embed)

Error running RunSWNE

While running SWNE Seurat pipeline I received the following error:

> swne.embedding <- RunSWNE(cells.seurat, k = 16, genes.embed = genes.embed, sample.groups = cell.clusters)
Error in ExtractNormCounts(object, obj.type = "seurat", rescale = F, rescale.method = "log", :
unused argument (rescale = F)

It seems as if RunSWNE() calls ExtractNormCount() with argument rescale = F whereas rescale is not defined.

Seurat- SCTransform compatibility?

Seems similar to #25.

Typical PBMC 5K data, preprocessed and clustered in Seurat (and native SCTransform).

FindNeighours done, UMAP generated. But
swne.embedding <- RunSWNE(data_transcripts_seurat, k = 20)

calculating variance fit ... using gam [1] "4800 variable genes to use"
Computing nearest neighbor graph
Computing SNN
Error in as(object@graphs$RNA_snn, "dgCMatrix") : 
  no method or default for coercing “NULL” to “dgCMatrix”
In addition: Warning message:
In pf(exp(df$res), n.obs, n.obs, lower.tail = F, log.p = F) : NaNs produced

Checking my seurat object, it turns out there's no RNA_snn, but instead there's SCT_nn and SCT_snn.

Would this error be solved by making SWNE look for object@graphs$SCT_snn instead? If so, how?

Error with k=2

FindNumFactors identifies k=2 as the best choice for my data, which makes biological sense. This may mean that swne is not the most natural choice for visualizing my data, but we are interested in identifying subclusters along that axis and I thought it was worth trying. With k=2, I get the following error:

> swne.embedding <- EmbedSWNE(nmf.scores, snn.matrix, alpha.exp = 1.0, snn.exp = 1, n_pull = 4, dist.use = "IC")
Error in cmdscale(d, k) : 'k' must be in {1, 2, ..  n - 1}
In addition: Warning messages:
1: In MASS::bcv(x) : minimum occurred at one end of the range
2: In MASS::bcv(y) : minimum occurred at one end of the range

> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.4 LTS

Matrix products: default
BLAS: /usr/lib/atlas-base/atlas/libblas.so.3.0
LAPACK: /usr/lib/atlas-base/atlas/liblapack.so.3.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] mgcv_1.8-23    nlme_3.1-131.1 swne_0.2.1     dplyr_0.7.4    Seurat_2.2.1   Matrix_1.2-11  cowplot_0.9.2 
[8] ggplot2_2.2.1 

thanks

SWNE plotting of samples subsets

I have merged different samples using seurat and then run SWNE. What would be the best way to show a subset (i.e. different samples) in the SWNE plot, while maintaining the overall structure of the SWNE plot. thanks

Offical Seurat 3.0 Tutorial

Thank you for creating this awesome tool. I have two questions, one related to Github/SWNE and one just for SWNE:

  1. Would you be able to create a tutorial for using SWNE with a Seurat 3.0 object?
  2. I recall that a Single-cell Webinar for SWNE had taken place on Friday April 26th. Do you happen to have a recording for that webinar?

some bugs in testing "1. A basic walkthrough of 3k PBMC cells starting from a pre-computed Seurat object."

Hi,
when I was testing the first walkthrough by the test data, I met a error at the step "Runs the SWNE embedding" :
swne.embedding <- EmbedSWNE(nmf.scores, snn, alpha.exp = alpha.exp, snn.exp = snn.exp,n_pull = n_pull, dist.use = "IC")
the error information is Error in get_factor_coords(H.smooth, method = proj.method, pca.red = pca.red, : Distance must be one of: pearson, IC, cosine, euclidean
then, I used my own data to test the tutorial ,but got the same error. And I didn't change any steps in the tutorial.
could you please give me some advice about it ?
Much thanks !

Unlisted dependencies

Thanks for providing the code. Hoping to get in running soon. But, I ran into some issues while trying to install. Many dependencies are not listed anywhere. I found them one-by-one in the resultant error messages over multiple swneinstallation attempts. I had to install each of the following (and I may have missed one or more during the process):

BiocManager::install("TxDb.Hsapiens.UCSC.hg38.knownGene", version = "3.8")
BiocManager::install("org.Hs.eg.db")
devtools::install_github("aertslab/RcisTarget")
devtools::install_github("aertslab/AUCell")
devtools::install_github("aertslab/cisTopic")

Also, getting the following warnings many times during installation process.

In file included from swne_cpp_funcs.cpp:2:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigen.h:25:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/RcppEigenForward.h:39:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/unsupported/Eigen/Polynomials:135:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/unsupported/Eigen/../../Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop

Did actually install, even with these warnings, however.

re variable genes used does not match

Hi,

I'm having some trouble with the variable genes selection for the RunSWNE Seurat wrapper function. I have my integrated data Seurat object and I follow the steps outlined here: https://yanwu2014.github.io/swne/Examples/multiple_pancreas_alignment_swne.html

However, when running the RunSWNE() command to create the swne.embeddings, instead of [1] "2000 variable genes to use", I see [1] "15760 variable genes to use" in the Console. This is the total number of genes in the dataset, not just the variable genes. Even when I specifically set genes.use <- VariableFeatures(obj), I get the same read in the Console (i.e. all genes are being used). I noticed that the pancreas_integrated_seurat.Robj object in the vignette is already subseted to only the 2000 most variable genes. I'm wondering if the Console is printing the total number of genes in the dataset or if it's actually using all genes and not just the variable ones?

Thanks!

Same code, different SWNE imbeddings

Hi,

I'm running into an interesting problem where each iteration that I run the same code, I get a subtly different output. Am I leaving a critical argument out of the command that will correct for this?


load("path/Idents_ordered_ma_v6_res0.75.Robj")

obj <- Idents_ordered_ma_v6_res0.75
obj1 <- Idents_ordered_ma_v6_res0.75
obj2 <- Idents_ordered_ma_v6_res0.75
obj3 <- Idents_ordered_ma_v6_res0.75
obj4 <- Idents_ordered_ma_v6_res0.75
obj5 <- Idents_ordered_ma_v6_res0.75

#Obj
obj <- RunSWNE(obj, k = 14, genes.embed = genes.embed, return.format = "seurat")
DimPlot(obj, reduction = "swne")

obj dimplot.pdf

#Obj1 
obj1 <- RunSWNE(obj1, k = 14, genes.embed = genes.embed, return.format = "seurat")
DimPlot(obj1, reduction = "swne")

obj1 dimplot.pdf

#obj2 
obj2 <- RunSWNE(obj2, k = 14, genes.embed = genes.embed, return.format = "seurat")
DimPlot(obj2, reduction = "swne")

obj2 dimplot.pdf

#obj3 
obj3 <- RunSWNE(obj3, k = 14, genes.embed = genes.embed, return.format = "seurat")
DimPlot(obj3, reduction = "swne")

obj3 dimplot.pdf

#obj4 
obj4 <- RunSWNE(obj4, k = 14, genes.embed = genes.embed, return.format = "seurat")
DimPlot(obj4, reduction = "swne")

obj4 dimplot.pdf

#obj5 
obj5 <- RunSWNE(obj5, k = 14, genes.embed = genes.embed, return.format = "seurat")
DimPlot(obj5, reduction = "swne")

obj5 dimplot.pdf

Thanks!

Seurat V3 Workflow

I ran the code you sent

AssayData(se.obj, slot = "counts") <- FilterData(AssayData(se.obj, slot = "counts"), min.samples.frac = 0.0025, min.nonzero.features = 200, trim = 0.0025)

and got the following error

Error in AssayData(se.obj, slot = "counts") : could not find function "AssayData"

I have loaded swne, Seurat, Matrix, ggplot2. what package isnt loaded?

Installation error -- Velocyto

Hello All,
I'm getting the following error upon installation --

Error: package or namespace load failed for ‘swne’ in namespaceExport(ns, exports):
undefined exports: PlotSWNEVelocyto, VelocytoArrows
Error: loading failed
Execution halted

I assume this is due to the recent change removing velocyto?

Bringing a seurat v3 object into SWNE

Hi, I have used SWNE before to study an object that I generated in Seurat v2.

However, with a Seurat version 3 object, I am unsure how to extract the necessary information to run a SWNE analysis.

Previously, I was able to run:

se.obj <- OBJECT

[email protected] <- FilterData(as([email protected], "dgCMatrix"), min.samples.frac = 0.0025, 
                              min.nonzero.features = 200, trim = 0.0025)

norm.counts <- ExtractNormCounts(se.obj, obj.type = "seurat", rescale = T, rescale.method = "log", batch = NULL) 

and then proceed with my swne analysis.

However, I am unsure how to bring this information out of a Seurat v3 object.

Thoughts?

Change in behaviour (output) of FindNumFactors

There a change in the output format of FindNumFactors. It is not longer a list nor does it compute a k value. This change has not been documented and the version number has not be incremented to indicate that there is a change. This has caused my existing pipeline which calls this function and the output k parameter to give an error an abort.

Please ensure that functions are backwards-compatible and produce the same output variables. To change the behaviour of a function drastically, please deprecate the existing version and create a function with a different name. This will cause less disruption for users with existing code that calls these functions.

how to use contour.geom in PlotSWNE

Hi, teams
I find "contour.geom" in the function "PlotSWNE", which plots contour as either a line or a filled-in region. The source code shows it needs a "contour.data" in the "swne.embedding" object, but there is no way to generate it in the package "swne". So, how could I make use of the options "contour.geom"

Formatting issue in error message

Formatting issue in error message when calling EmbedSWNE with dist.metric = "correlation":

swne_embedding <- EmbedSWNE(nmf.scores, snn, alpha.exp = alpha.exp, snn.exp = snn.exp,
+ n_pull = n_pull, dist.use = dist.metric)
Error in get_factor_coords(H.smooth, method = proj.method, pca.red = pca.red, :
Distance must be one of: pearsonDistance must be one of: ICDistance must be one of:
cosineDistance must be one of: euclidean

mitochondrial/UMI regression

Hi!

This is a really great tool you have developed. I was wondering is there any way built into the package to regress out the variation in mitochondrial content or number of UMI? I know this is possible in the Seurat pipeline, but it appears you recommend to begin the swne pipeline with the raw seurat matrix.

Would I be able to use my scaled and regressed data matrix from the seurat object as long as I do not center it with a mean of 0?

Best,
Dylan

Unable to replicate results for SWNE Walkthrough using Seurat

Hi,

I followed the example given in
https://yanwu2014.github.io/swne/Examples/pbmc3k_swne_seurat.html

However, I could not get back the same clustering as shown in the example (please find attached the clusters test_swne.pdf )

The following warning messages were obtained while I ran the following command:
swne.embedding <- RunSWNE(obj, k = 16, genes.embed = genes.embed)

Warning messages:
1: In system.time(out <- .Call("NNLM_nnmf", A, as.integer(k), init.mask$Wi, :
Target tolerance not reached. Try a larger max.iter.
2: In if (return.format == "embedding") { :
the condition has length > 1 and only the first element will be used

Is the difference in clustering due to an issue with NNLM package? I noted that it was removed from the CRAN repository.

EmbedSWNE fails

Hi,

I have a large dataset with more than 20k cells. trying

swne.embedding <- EmbedSWNE(nmf.scores, snn, alpha.exp=alpha.exp, snn.exp=snn.exp, n_pull=3, dist.use='IC')

I get the following error:

Error in SNN %*% t(H) : 
  Cholmod error 'X and/or Y have wrong dimensions' at file ../MatrixOps/cholmod_sdmult.c, line 90

although the dimensions should match (after subsetting snn to the relevant cells):

dim(nmf.scores)
[1]     4 20565
dim(snn)
[1] 20565 20565

any ideas what's wrong here?

thanks!

primary steps uploading seurat object

I'm trying to filter the data of my Seurat matrix and extract the norm counts based off the posted walk through. First I was wondering how necessary it is to filter given my imported object was already filtered in Seurat.
My bigger question though, is that both the filtering and extracting norm counts seem to require the raw data of the object to be an S4 object of dgCMatrix class.
The current object I'm trying to use has the data in this format, but the raw data is still an S3 data frame. Is there any way to get around this or is there a way to reformat the raw data within the object?

SWNE plotting on Tabular Data

Hi Team,

I have followed the steps for plotting SWNE on genome data. Now i want to plot SWNE on my custom dataset which is nothing but Structured Tabular data.
So is there any plugin or module for plotting SWNE on my custom dataset?
Please help me out with this.

Thanks in advance

SWNE bioconductor compatability

Hello,
Just wondering if it's possible to runSWNE on a SingleCellExperiment? Would love to try but can't see anything on any of the forums about it. Is it possible?
Thanks!

Transferring metadata from a Seurat object into SWNE

Hi!

I really like this tool. It grabs the best elements of a umap and a trajectory plot :)

My question is about using a Seurat object as an input.
I have an object which is the result of several libraries merged together. So, the metadata stored on the Seurat object would be crucial to be carried over into NMF -> SWNE, but only the counts are extracted.

Could you tell me how to transfer the metadata into the SWNE process and how to call then for plotting with PlotSWNE?

Thank you!

hemato_swne_pseudotime_plot fail to function

In reproducing the figure from the script:

pseudotime <- cds$Pseudotime; names(pseudotime) <- colnames(cds@reducedDimS);

pdf("hemato_swne_pseudotime_plot.pdf", width = 6, height = 5)
FeaturePlotSWNE(swne.embedding, pseudotime, alpha.plot = 0.4, label.size = 3.5, pt.size = 1.5)
Error in quantile.default(feature.scores, probs = quantiles) :
missing values and NaN's not allowed if 'na.rm' is FALSE

While other parts of the scripts worked well, the function failed. Is it possibly due to some bugs in the script? Thanks.

OpenBLAS Warning for FindNumFactors

Thank you for creating this great visualization tool! I am currently running through the tutorial and following warning prints out endlessly when I try to run the FindNumFactors function.

OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.

Would you happen to know what this means?

Error in as(object@graphs$RNA_snn, "dgCMatrix")

Thank you for creating this package. I tried to run it using a Seurat objet.

library(Seurat)
library(swne)
obj <- readRDS(file = "obj.rds")
clusters <- obj$seurat_clusters
genes.embed <- c("ENSMUSG00000031766", "ENSMUSG00000041644", "ENSMUSG00000001025", "ENSMUSG00000030963", "ENSMUSG00000032060", "ENSMUSG00000026726", "ENSMUSG00000027202", "ENSMUSG00000062209", "ENSMUSG00000054640", "ENSMUSG00000027070", "ENSMUSG00000041959", "ENSMUSG00000060803", "ENSMUSG00000097830")
swne.embedding <- RunSWNE(obj, k = 16, genes.embed = genes.embed)

Then I've got the following error:
Error in as(object@graphs$RNA_snn, "dgCMatrix") :
no method or default for coercing “NULL” to “dgCMatrix”

Is there anyway to solve this issue? Thank you very much!

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.