GreenleafLab / ArchR

ArchR : Analysis of Regulatory Chromatin in R (www.ArchRProject.com)
MIT License
388 stars 140 forks source link

Harmony - downstream analysis not working #1531

Closed jshi7 closed 2 years ago

jshi7 commented 2 years ago

Hello,

After calling addHarmony, downstream clustering/UMAP doesn't work with the "harmony" reducedDim for me. It gives this error on addClusters and addUMAP: Error: $ operator is invalid for atomic vectors

I tried with both tutorial dataset and my own dataset and attached the log files for the tutorial dataset. harmony-59054622.log

ArchR-addClusters-1d82ae6d4044-Date-2022-07-30_Time-14-17-00.log

Thank you!

rcorces commented 2 years ago

Hi @jshi7! Thanks for using ArchR! Please make sure that your post belongs in the Issues section. Only bugs and error reports belong in the Issues section. Usage questions and feature requests should be posted in the Discussions section, not in Issues.
Before we help you, you must respond to the following questions unless your original post already contained this information: 1. If you've encountered an error, have you already searched previous Issues to make sure that this hasn't already been solved? 2. Can you recapitulate your error using the tutorial code and dataset? If so, provide a reproducible example. 3. Did you post your log file? If not, add it now. 4. Remove any screenshots that contain text and instead copy and paste the text using markdown's codeblock syntax (three consecutive backticks). You can do this by editing your original post.

rcorces commented 2 years ago

Sorry, I'm unable to recapitulate your error on the tutorial data with the current master branch (release_1.0.2). I'm also not sure why you get this message "done-3!".


> projHeme5 <- addHarmony(
+     ArchRProj = projHeme5,
+     reducedDims = "IterativeLSI",
+     name = "Harmony2",
+     groupBy = "Sample"
+ )
Harmony 1/10
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Harmony 2/10
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Harmony 3/10
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Harmony converged after 3 iterations

> projHeme5@reducedDims
List of length 3
names(3): IterativeLSI Harmony Harmony2
> projHeme5@reducedDims$Harmony2
List of length 5
names(5): matDR params date scaleDims corToDepth

> projHeme5 <- addClusters(
+     input = projHeme5,
+     reducedDims = "Harmony2",
+     method = "Seurat",
+     name = "Clusters_Harmony2",
+     resolution = 0.8
+ )
ArchR logging to : ArchRLogs/ArchR-addClusters-43076a2671a5-Date-2022-07-31_Time-10-56-39.log
If there is an issue, please report to github with logFile!
2022-07-31 10:56:41 : Running Seurats FindClusters (Stuart et al. Cell 2019), 0.028 mins elapsed.
Computing nearest neighbor graph
Computing SNN
Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck

Number of nodes: 10251
Number of edges: 434617

Running Louvain algorithm...
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Maximum modularity in 10 random starts: 0.8594
Number of communities: 14
Elapsed time: 0 seconds
2022-07-31 10:56:53 : Testing Outlier Clusters, 0.237 mins elapsed.
2022-07-31 10:56:53 : Assigning Cluster Names to 14 Clusters, 0.237 mins elapsed.
2022-07-31 10:56:53 : Finished addClusters, 0.239 mins elapsed.
jshi7 commented 2 years ago

my bad, I should have specified that I used version 1.0.3 - I will try using 1.0.2 (and the done-3 message I printed for troubleshooting purposes haha)

jshi7 commented 2 years ago

It works with 1.0.2 - sorry for not checking this beforehand and thank you for your help!

Zepeng-Mu commented 2 years ago

I'm seeing the same error message while using dev branch. I think this happened in the getReducedDims function.

#Get Dimensions
    if(scaleDims){
      corToDepth <- ArchRProj@reducedDims[[reducedDims]]$corToDepth$scaled
      matDR <- .scaleDims(ArchRProj@reducedDims[[reducedDims]][[1]])
    }else{
      if(is.na(ArchRProj@reducedDims[[reducedDims]]$corToDepth[1])){
        corToDepth <- rep(0, ncol(ArchRProj@reducedDims[[reducedDims]][[1]]))
        matDR <- ArchRProj@reducedDims[[reducedDims]][[1]]
      }else{
        corToDepth <- ArchRProj@reducedDims[[reducedDims]]$corToDepth$none
        matDR <- ArchRProj@reducedDims[[reducedDims]][[1]]
      }
    }

in previous versions versus

dimsAvailable <- 1:length(ArchRProj@reducedDims[[reducedDims]]$corToDepth$none)

in dev. This ArchRProj@reducedDims[[reducedDims]]$corToDepth should be NA but not none I think. And this is causing the error.

rcorces commented 2 years ago

@Zepeng-Mu - Good catch. I think this should be fixed on dev now via https://github.com/GreenleafLab/ArchR/commit/a9ef2ab61d6b552844a271c85d7e309e8130156f