r3fang / SnapATAC

Analysis Pipeline for Single Cell ATAC-seq
GNU General Public License v3.0
301 stars 125 forks source link

runMagic segfault error #105

Closed RZiffra closed 4 years ago

RZiffra commented 4 years ago

Hi Rongxin,

Whenever I try to run the runMagic function on large samples (i.e. 77K cells & 93K cells) I keep getting a segfault error. I have also tried with small number of genes (16) and large numbers (58K). When I run the function with smaller numbers of cells (i.e. 5K & 27K) I don't run into this error.

x.sp <- readRDS("AllPrimary_LSA_Harmony_PreMagic.snap.rds") x.sp = runMagic(

  • obj=x.sp,
  • input.mat="gmat",
  • step.size=3
  • ) Epoch: checking the inputs ...

caught segfault address 0xffffffff92b506b0, cause 'memory not mapped'

Traceback: 1: A %% A 2: A %% A 3: runMagic(obj = x.sp, input.mat = "gmat", step.size = 3)

Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace

r3fang commented 4 years ago

Hi Ryan,

If you are using this function just for annotation. I recommend to use a subset of cells. Indeed this function is bit hard to deal with large dataset.

Sent from my iPhone

On Sep 26, 2019, at 11:54 AM, RZiffra notifications@github.com wrote:

Hi Rongxin,

Whenever I try to run the runMagic function on large samples (i.e. 77K cells & 93K cells) I keep getting a segfault error. I have also tried with small number of genes (16) and large numbers (58K). When I run the function with smaller numbers of cells (i.e. 5K & 27K) I don't run into this error.

x.sp <- readRDS("AllPrimary_LSA_Harmony_PreMagic.snap.rds") x.sp = runMagic(

obj=x.sp, input.mat="gmat", step.size=3 ) Epoch: checking the inputs ... caught segfault address 0xffffffff92b506b0, cause 'memory not mapped'

Traceback: 1: A %% A 2: A %% A 3: runMagic(obj = x.sp, input.mat = "gmat", step.size = 3)

Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

suragnair commented 4 years ago

You can try this (described in #149) :

myRunMagic <- function (obj, input.mat, step.size) {
    A = obj@graph@mat;
    data.use = obj@gmat;

    # smooth
    A = A + t(A);
    A = A / Matrix::rowSums(A);
    data.use.smooth = A %*% data.use;
    if(step.size > 1){
        for(i in 1:step.size){
            data.use.smooth = A %*% data.use.smooth;
        }
    }

    slot(obj, input.mat) = data.use.smooth;    
    return(obj)
}

In the original implementation step.size of 3 would compute A^8, whereas it would compute A^3 in the above. But it is much faster and memory efficient.

RZiffra commented 4 years ago

Thanks, this works well!