Can objects generated by genotypes be saved locally?

41 views
Skip to first unread message

Fuchuan Han

unread,
Mar 20, 2024, 11:36:40 AM3/20/24
to Core Hunter Users
Hi,Since I have 1000 samples, 8M snps, I want to split multiple scripts to run sampleCore, but every time I need to run genotypes first to calculate the chdata it takes too long, is it possible to save the chdata format variable output by genotypes locally, so that all the scripts can call the variable directly, which saves a lot of time and computational resources.

Herman De Beukelaer

unread,
Mar 20, 2024, 12:04:48 PM3/20/24
to Core Hunter Users
Hi,

Serialising with saveRDS won't work out of the box because the core hunter data object contains a nested Java object. Java objects cannot be serialised with saveRDS. However, rJava (used by Core Hunter to interact with Java) provides its own .jserialize function. The Java object is in the data$java slot of your data object (essentially an R list with custom S3 functions). You could try to serialise the data$java part first with .jserialize:

data$java <- .jserialize(data$java)

Then store your data object to RDS:

saveRDS(data$java, file = ...)

If that works (didn't try it yet) you could afterwards deserialise with

data <- readRDS(...)
data$java <- .junserialize(data$java)

Can you let me know if this works? If not, I will have a try myself to see what's going wrong. If it does work, maybe we could include a custom serialisation function for core hunter data that does this for you.

Op woensdag 20 maart 2024 om 16:36:40 UTC+1 schreef Fuchuan Han:
Reply all
Reply to author
Forward
0 new messages