sam2matrix