getsex function error.
0
0
Entering edit mode
zusman • 0
@eb7ee52d
Last seen 23 months ago
Germany

Hi, I am running a script where I want to get sexes of the samples using getsex. When i load the data file i can clearly see there are male and female samples in it. Also everything goes perfectly until it reaches getsex function and i get caught segfault address 0x1, cause 'memory not mapped' along with traceback options which i am sure problem lies with getsex function. Can some one help me identify what could be the reason. Computing power is maximum 40 G still throws the error so memory is not the issue.

Code should be placed in three backticks as shown below

#loading the sample sheet
load(paste0(path, "sample_sheets/sample_sheet_fit.RData"))
print(ss_t)
dim(ss_t) 

file.exists(paste0(dpath,ss_t$fileloc,"_Grn.idat")) %>% all %>% stopifnot
file.exists(paste0(dpath,ss_t$fileloc,"_Red.idat")) %>% all %>% stopifnot
num_samps <- 100
num_its   <- ceiling(nrow(ss_t) / num_samps)

qcres <- lapply(1:num_its, function(i) {

    low_ind <- (i-1)*num_samps + 1
    hgh_ind <- min(nrow(ss_t), i*num_samps)

print(i)    #zu
print(c(low_ind, hgh_ind)) #zu

#reading in the data from idat files
print ("Reading .idat files")
RGset <- read.metharray(paste0(dpath,ss_t$fileloc[low_ind:hgh_ind]), verbose = TRUE)

#processing - RGset_raw contains only methylated and unmethylated signals.
print("Getting methylated and unmethylated signals")
RGset_raw <- preprocessRaw(RGset)
print(RGset_raw)
#predicting sex
pred_sex <- getSex(mapToGenome(ratioConvert(RGset_raw, what = "both", keepCN = TRUE)))
psex <- as.data.frame(pred_sex)

#quality control function
qc <- getQC(RGset_raw)
head(qc)

return(list(psex = psex, qc = qc))
})

predsex <- map(qcres, "psex") %>% 
             do.call(rbind,.) %>% 
             select(-predictedSex) #determining predicted elsewhere

dim(predsex) #[1] 600   3
predsex$sentrix_id <- rownames(predsex)

qcint   <- map(qcres,"qc") %>% do.call(rbind,.) %>% as.data.frame(stringsAsFactors=F)
dim(qcint) #[1] 600   2
qcint$sentrix_id <- rownames(qcint)

setequal(qcint$sentrix_id, predsex$sentrix_id) %>% stopifnot
(!any(duplicated(qcint$sentrix_id)))           %>% stopifnot
(!any(is.na(qcint$sentrix_id)))                %>% stopifnot

# final data frame
qcres <- inner_join(qcint, predsex) %>% 
           mutate(yx_diff = yMed - xMed, med_intensity = (mMed + uMed)/2)

save(qcres, file = paste0(opath,"qc_results.RData"))



# OUTPUT  
*** caught segfault ***
address 0x1, cause 'memory not mapped'

Traceback:
 1: colMedians(CN, rows = xIndex, na.rm = TRUE)
 2: colMedians(CN, rows = xIndex, na.rm = TRUE)
 3: .getSex(CN = CN, xIndex = xIndex, yIndex = yIndex, cutoff = cutoff)
 4: getSex(mapToGenome(ratioConvert(RGset_raw, what = "both", keepCN = TRUE)))
 5: FUN(X[[i]], ...)
 6: lapply(1:num_its, function(i) {    low_ind <- (i - 1) * num_samps + 1    hgh_ind <- min(nrow(ss_t), i * num_samps)    print(i)    print(c(low_ind, hgh_ind))    print("Reading .idat files")    RGset <- read.metharray(paste0(dpath, ss_t$fileloc[low_ind:hgh_ind]),         verbose = TRUE)    print("Getting methylated and unmethylated signals")    RGset_raw <- preprocessRaw(RGset)    print(RGset_raw)    pred_sex <- getSex(mapToGenome(ratioConvert(RGset_raw, what = "both",         keepCN = TRUE)))    psex <- as.data.frame(pred_sex)    qc <- getQC(RGset_raw)    head(qc)    return(list(psex = psex, qc = qc))})
 7: lapply(1:num_its, function(i) {    low_ind <- (i - 1) * num_samps + 1    hgh_ind <- min(nrow(ss_t), i * num_samps)    print(i)    print(c(low_ind, hgh_ind))    print("Reading .idat files")    RGset <- read.metharray(paste0(dpath, ss_t$fileloc[low_ind:hgh_ind]),         verbose = TRUE)    print("Getting methylated and unmethylated signals")    RGset_raw <- preprocessRaw(RGset)    print(RGset_raw)    pred_sex <- getSex(mapToGenome(ratioConvert(RGset_raw, what = "both",         keepCN = TRUE)))    psex <- as.data.frame(pred_sex)    qc <- getQC(RGset_raw)    head(qc)    return(list(psex = psex, qc = qc))})
QualityControl methylationArrayAnalysis • 862 views
ADD COMMENT

Login before adding your answer.

Traffic: 989 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6