Giter Site home page Giter Site logo

rphenograph's Introduction

R implementation of the PhenoGraph algorithm

Rphenograph

A simple R implementation of the PhenoGraph [1] algorithm, which is a clustering method designed for high-dimensional single-cell data analysis. It works by creating a graph ("network") representing phenotypic similarities between cells by calclating the Jaccard coefficient between nearest-neighbor sets, and then identifying communities using the well known Louvain method in this graph.

Installation

To install the latest version from the github repository, use:

if(!require(devtools)){
  install.packages("devtools") # If not already installed
}
devtools::install_github("JinmiaoChenLab/Rphenograph")

Usage

After installing the package, use the following code to run a simple example (to install, see below).

iris_unique <- unique(iris) # Remove duplicates
data <- as.matrix(iris_unique[,1:4])
Rphenograph_out <- Rphenograph(data, k = 45)
modularity(Rphenograph_out[[2]])
membership(Rphenograph_out[[2]])
iris_unique$phenograph_cluster <- factor(membership(Rphenograph_out[[2]]))
ggplot(iris_unique, aes(x=Sepal.Length, y=Sepal.Width, col=Species, shape=phenograph_cluster)) + geom_point(size = 3)+theme_bw()

Reference

[1] Levine JH, Simonds EF, Bendall SC, Davis KL, Amir ED, Tadmor MD, et al. Data-Driven Phenotypic Dissection of AML Reveals Progenitor-like Cells that Correlate with Prognosis. Cell. Elsevier Inc.; 2015; 1–14. doi:10.1016/j.cell.2015.05.047

rphenograph's People

Contributors

haoeric 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rphenograph's Issues

Changing clustering resolution

Hello

I'm currently changing the clustering resolution (increasing or decreasing the number of output clusters) by changing the KNN parameter.
Is there a way to change the resolution by changing the Louvain parameters and not the KNN?

Thanks

Rphenograph doesn't recognize my clean dataset

Hi,

I have removed all NAs from my dataframe and I am trying to run Rphenograph.

I checked the number of missing values in my dataset to ensure it is complete, and the answer to the code below is 0.

sum(is.na(mydata))

I also checked to see if my dataset had any characters, and the answer to the code below was 0.

sum(is.character(mydata))

Now, I am running my Rphenograph (code below).

set.seed(436)
Rphenograph_out <- Rphenograph(mydata, k = 45)

However, I am getting this error:

Run Rphenograph starts:
-Input data of 40178 rows and 10 columns
-k is set to 45
Finding nearest neighbors...Warning: NAs introduced by coercionWarning: NAs introduced by coercionError in nn2(data, data, k, searchtype = "standard") :
NA/NaN/Inf in foreign function call (arg 1)

How would I fix this? It appears Rphenograph has trouble recognizing that my dataset does not have NAs.

Thanks in advance!

Rphenograph data output issue?

Trying to run the Rphenograph function; it seems to remove one entry.

Run Rphenograph starts:
-Input data of 366047 rows and 8 columns
-k is set to 10

But the output matrix has 366046 rows.

Wondering if someone may have insights to this please?

Thanks!

Error in if (length(attrs) != 0 && (is.null(nam) || any(nam == ""))) { :

Hello,

I have encountered an issue when using the Rphenograph function, with my personal data and with the example iris data. It looks like the jacquard coefficients are computed, but then non of these is >0, resulting in a matrix of 0 rows in the "links" object. Do you have any idea of how the problem may be fixed?

Thanks in advance

Weird error when working with a lot of cells

Hi there,

Thanks for this useful package. I'm running it with a total of 1,5 millions of cells considering only 10 features and I'm getting this weird error, together with a (also very weird) PCA:

Run Rphenograph starts:
  -Input data of 1500000 rows and 10 columns
  -k is set to 15
  Finding nearest neighbors...DONE ~ 1236.863 s
  Compute jaccard coefficient between nearest-neighbor sets...DONE ~ 110.193 s
  Build undirected graph from the weighted links...DONE ~ 110.629 s
  Run louvain clustering on the graph ...DONE ~ 135.736 s
Run Rphenograph DONE, totally takes 1593.421s.
  Return a community class
  -Modularity value: 0.8961815
  -Number of clusters: 31Warning messages:
1: In recycleSingleBracketReplacementValue(value, x, i) :
  number of values supplied is not a sub-multiple of the number of values to be replaced

image

I tried to repeat the clustering with less cells (a total of 15.000) and none warning is appearing and the PCA is correctly colored (apparently)...

image

...maybe this could be a bug when working with so much cells? Thanks a lot for your help!

Could not download the Rphenograph package

Hi guys,

I followed the instructions below to install the Rphenograph:

library(data.table)
if(!require(devtools)){

  • install.packages("devtools") # If not already installed
    
  • }

devtools::install_github("JinmiaoChenLab/Rphenograph")

However, I kept getting the output (below) and could not have the package Rphenograph:

tar: Failed to set default locale
tar: Failed to set default locale
During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_TIME failed, using "C"
3: Setting LC_MESSAGES failed, using "C"
4: Setting LC_MONETARY failed, using "C"
v checking for file '/private/var/folders/hz/6k6njk1d2sv2r0dvffd3ktvh0000gn/T/Rtmp2nUveF/remotes21af753481b1/JinmiaoChenLab-Rphenograph-0298487/DESCRIPTION' ...

  • preparing 'Rphenograph':
    v checking DESCRIPTION meta-information ...
  • cleaning src
  • checking for LF line-endings in source and make files and shell scripts
  • checking for empty or unneeded directories
  • building 'Rphenograph_0.99.1.tar.gz'

Error: (converted from warning) Setting LC_CTYPE failed, using "C"
Execution halted
Error in i.p(...) :
(converted from warning) installation of package '/var/folders/hz/6k6njk1d2sv2r0dvffd3ktvh0000gn/T//Rtmp2nUveF/file21af32982531/Rphenograph_0.99.1.tar.gz' had non-zero exit status

Can anyone help me please? Thank you so so much.

An error I don't know the reason

Error in nn2(data, data, k, searchtype = "standard") :
NA/NaN/Inf in foreign function call (arg 1)
Timing stopped at: 9.753 19.37 29.14

image

Actually I can check document of nn2

Error run Rphenograph (function 'enterRNGScope' not provided by package 'Rcpp'**)

I've been trying to run the example code that you provided but ran into the following error (at the end). Anything I'm missing?

library("Rphenograph")
Loading required package: ggplot2
Loading required package: igraph

Attaching package: ‘igraph’

The following objects are masked from ‘package:stats’:

decompose, spectrum

The following object is masked from ‘package:base’:

union

Warning message:
package ‘ggplot2’ was built under R version 4.0.2

iris_unique <- unique(iris) # Remove duplicates
data <- as.matrix(iris_unique[,1:4])
Rphenograph_out <- Rphenograph(data, k = 45)
Run Rphenograph starts:
-Input data of 149 rows and 4 columns
-k is set to 45
Finding nearest neighbors...DONE ~ 0.002 s
Compute jaccard coefficient between nearest-neighbor sets...Error in jaccard_coeff(neighborMatrix) :
function 'enterRNGScope' not provided by package 'Rcpp'

Timing stopped at: 0.059 0.001 0.059

Thank you.

I load the Phenograph package, but I keep getting the error "could not find function "Rphenograph"

I installed the Phenograph package with the following code:

Load data.table package

library(data.table)

Load Phenograph

if(!require(devtools)){
install.packages("devtools") # If not already installed
}
devtools::install_github("JinmiaoChenLab/Rphenograph")

When I try to use the Rphenograph function, I get an error:

data<- df_phenograph
Rphenograph_out <- Rphenograph(data, k = 30)

"Error in Rphenograph(data, k = 30) :
could not find function "Rphenograph"

Any idea why this could be happening? Thank you.

Unclustered data

Hi,

Have enjoyed using your package, just had an issue with cases where samples remain unclustered.

On using lower values of k, some data remains unclustered. Is it possible to add these to the output membership (unconnected components of the graph), as currently these are removed from the final output and it's difficult to retrace which samples these are.

Thank you

Extracting full list of clusters

In your iris example, when you execute membership(Rphenograph_out[[2]]) you get a list of flower indices (1-149) and their associated Rphenograph cluster they belong to as shown below.

Screen Shot 2020-05-11 at 22 35 44

Do you know how I can extract the list of clusters, as shown individually, in the correct order? so I want something like 111111..22222..23123.... etc

Mojave

Hi,
I tried installing Rphenograph on a Mac Mojave system and I'm getting a 'clang' result. See below. My HighSierra systems install fine.

It appears that the devtools are in a new location. Is that it? What should I do?

paste

devtools::install_github("JinmiaoChenLab/Rphenograph")

Downloading GitHub repo JinmiaoChenLab/Rphenograph@master
checking DESCRIPTION meta-information ...9/d5121s9d2tqgvbhz95zr0hy9s5mm48/T/RtmphDNQWc/remotes20e4444f5901/JinmiaoChenLab-Rphenograph-0298487/DESCRIPTION’ ...
Installing package into ‘/Users/lirapd/Library/R/3.6/library’
(as ‘lib’ is unspecified)
'* installing source package ‘Rphenograph’ ...
** using staged installation
** libs
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Users/lirapd/Library/R/3.6/library/Rcpp/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
clang: warning: no such sysroot directory: '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk' [-Wmissing-sysroot]
In file included from RcppExports.cpp:4:
In file included from /Users/lirapd/Library/R/3.6/library/Rcpp/include/Rcpp.h:27:
In file included from /Users/lirapd/Library/R/3.6/library/Rcpp/include/RcppCommon.h:29:
In file included from /Users/lirapd/Library/R/3.6/library/Rcpp/include/Rcpp/r/headers.h:59:
In file included from /Users/lirapd/Library/R/3.6/library/Rcpp/include/Rcpp/platform/compiler.h:100:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:305:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:301:15: fatal error: 'math.h' file not found
#include_next <math.h>
^~~~~~~~
1 error generated.
make: *** [RcppExports.o] Error 1ERROR: compilation failed for package ‘Rphenograph’
'* removing ‘/Users/lirapd/Library/R/3.6/library/Rphenograph’
Error in i.p(...) :
(converted from warning) installation of package ‘/var/folders/y9/d5121s9d2tqgvbhz95zr0hy9s5mm48/T//RtmphDNQWc/file20e45a809919/Rphenograph_0.99.1.tar.gz’ had non-zero exit status

Rphenograph and igraph version 1.5.0 incompatible

Hi,

I have installed Rphenograph version 0.99.1 and I have igraph version 1.5.0 also installed. However, whenever I load the library for Rphenograph, and then try to load the library for igraph, Rphenograph gets deselected. They both do not have the check mark next to them at the same time. One gets loaded, but the other gets unloaded. This is not the case for my friend who has igraph version 1.4.3 installed and both packages can be loaded at the same time.

Specifically, this is the error that pops up on my iMac intel computer:

> library(Rphenograph)
Loading required package: igraphError in value[3L] :
      Package ‘igraph’ version 1.4.3 cannot be unloaded:
Error in unloadNamespace(package) : namespace ‘igraph’ is imported by ‘leiden’, ‘Seurat’ so cannot be unloaded

Weird error

When I construct a virtual matrix and I successfully run Rphenograph:
image

When I try to adapt it into real data, it goes wrong:
image

And here is the real data:
Uploading image.png…

Is it because the matrix is too large? The matrix size is 30004712*33

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.