Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readAllelicCountsFile() can be very slow (with suggested fix) #378

Open
luyh-xp opened this issue Dec 11, 2024 · 1 comment
Open

readAllelicCountsFile() can be very slow (with suggested fix) #378

luyh-xp opened this issue Dec 11, 2024 · 1 comment
Assignees
Labels

Comments

@luyh-xp
Copy link

luyh-xp commented Dec 11, 2024

I was running PureCN on results generated by the GATK4 Somatic CNV workflow upstream, and I notice that it takes hours for readAllelicCountsFile() to parse an allelic counts tsv file. Admittedly my tsv file is fairly large (~2.4M lines), but this is still way too time-consuming.

It turns out that most of the time is spent on a single line of code (readAllelicCountsFile.R, line 79):

alt(vcf) <- DNAStringSetList(lapply(inputCounts$ALT_NUCLEOTIDE, DNAStringSet))

As far as I understand it, lapply() is basically equivalent to the native R for loop and it is not very efficient. So I replace it with the following line:

alt(vcf) <- DNAStringSetList( split( inputCounts$ALT_NUCLEOTIDE, 1:length(vcf) ) )

And it drastically reduces the running time of this function to a few minutes. Therefore, I recommend the developers to incorporate this fix so that future users won't have to solve the same problem when they are running PureCN on GATK4 outputs. Thank you very much for maintaining this amazing project!

@lima1 lima1 self-assigned this Dec 11, 2024
@lima1 lima1 added the bug label Dec 11, 2024
@lima1
Copy link
Owner

lima1 commented Dec 11, 2024

Thanks @luyh-xp . I'm sorry, I never really used that code myself.

Would this even work?

alt(vcf) <- DNAStringSetList(as.list(inputCounts$ALT_NUCLEOTIDE))

lima1 added a commit that referenced this issue Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants