Repository navigation
Conversation
- Convert 1x1 matrix beta to numeric scalar in .fastlmm_core - Resolves test failure: 'FaSTLMM LL estimation is numerically stable' - Ensures consistency with test expectations and user API
- Add code to generate default individual IDs (ind1, ind2, ...) in MVP.Data.Numeric2MVP - Ensures consistency with other data converters (MVP.Data.Bfile2MVP) - Add test for MVP.Data.Numeric2MVP Marker-by-Individual format - Verifies fix for SetRows.bm error (Issue xiaolei-lab#116) - Tests data integrity and output file creation
- Fixed automatic format detection by correctly accounting for map file header - Replaced confusing marker_by_col logic with is_marker_by_row for clarity - Corrected assignment logic to properly handle Marker-by-Individual vs Individual-by-Marker formats - Improved row_names handling with proper drop=FALSE parameter - Resolves error: 'Illegal row index usage in extraction' in SetRows.bm
Updated the documentation for print_info to reflect the fix in R/MVP.Utility.r.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title
Fix
MVP.Data.Numeric2MVP"Illegal row index usage in extraction" error with large genotype matricesSummary
This PR resolves a critical bug in
MVP.Data.Numeric2MVPthat caused the function to crash with an "Illegal row index usage in extraction" error from thebigmemorypackage when processing large numeric genotype matrices, particularly in Marker-by-Individual format.Problem Statement
User-Reported Error
When using
MVP.Data.Numeric2MVPto load a large numeric genotype matrix (280 individuals × 15,323,838 markers), the function crashed with:Impact
Root Cause Analysis
Bug Location
File:
R/MVP.Data.r, functionMVP.Data.Numeric2MVPTechnical Root Cause
The function had three interconnected bugs in its format detection and data assignment logic:
1. Incorrect Format Detection Logic
The comparison was fundamentally flawed:
n= number of columns in numeric file (fromnumeric_scan())n_marker= number of markers from map file (butnumeric_scan()returnsrows + 1due to header handling)The function failed to account for the map file header, causing the comparison to be off by one. For a Marker-by-Individual file (15 markers × 10 individuals), the detection would incorrectly classify it based on the header mismatch.
2. Inverted Assignment Logic
When the format was incorrectly detected as Marker-by-Individual (
marker_by_col = TRUE):big.matrixbig.matrix, rows represent individuals, not markers1,000,000markers to rows causedSetRows.bmto fail because the matrix only had280rows (individuals)3. Missing Output File
The function did not create the
.geno.indfile with individual IDs, causing inconsistency with other data converters.Solution Implementation
1. Fixed Format Detection (Line 625-643)
Key improvements:
numeric_scan()returningrows + 1:n_marker <- numeric_scan(map_file)$m - 1is_marker_by_rowinstead of confusingmarker_by_col2. Fixed Assignment Logic (Line 654-675)
Key improvements:
3. Added Individual ID File (Line 676-679)
Consistency improvement:
MVP.Data.Bfile2MVP, etc.)Additional Fix: MVP.FaSTLMM.LL Beta Type
Issue
The
MVP.FaSTLMM.LLtest was failing becausebetawas returned as a 1×1 matrix instead of a scalar, causing attribute mismatch.Fix
This ensures consistency with user expectations and test assertions.
Testing
Test Coverage
Added comprehensive test in
tests/testthat/test_Data.R:Validation Steps
.geno.desc,.geno.bin,.geno.map,.geno.indFiles Changed
R/MVP.Data.r
MVP.Data.Numeric2MVPformat detection logic.geno.indfile generationR/MVP.FaSTLMM.LL.r
tests/testthat/test_Data.R
Backwards Compatibility
Breaking Changes
None. The fix corrects previously broken behavior.
Non-Breaking Improvements
.geno.ind) is now generated consistentlyMVP.FaSTLMM.LLis now a scalar (previously was matrix)Performance Impact
Minimal. The fix improves clarity and correctness without adding computational overhead.
Verification Instructions
For Reviewers
R CMD checkshould pass all testsFor Users
To verify the fix works with your data:
Related Issues
Checklist
Request: Please close those issues which are already resolved.