├── .Rbuildignore ├── .gitignore ├── DESCRIPTION ├── LICENCE ├── NAMESPACE ├── R └── timsr.R ├── README.md ├── examples └── get_data.R ├── man ├── MS1.Rd ├── TimsR-class.Rd ├── TimsR.Rd ├── cleanMem.Rd ├── download_bruker_proprietary_code.Rd ├── intensity_per_frame.Rd ├── min_max_measurements.Rd ├── peaks_per_frame_cnts.Rd ├── plot_TIC.Rd ├── query.Rd ├── retention_times.Rd ├── rt_query.Rd ├── setup_bruker_so.Rd ├── sub-TimsR-ANY-ANY-method.Rd ├── sub-TimsR-ANY-character-method.Rd ├── table2dt.Rd ├── tables_names.Rd └── tdf.tables.Rd └── ms1_ms2_intensities.png /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ms1_ms2_intensities.png 2 | examples 3 | LICENCE 4 | README.md 5 | .git 6 | .gitignore 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .RData 2 | .Rhistory 3 | R/dev 4 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: timsr 2 | Title: Easily Access timsTOF Data 3 | Version: 0.0.3 4 | Authors@R: 5 | c(person(given = "Mateusz Krzysztof", 6 | family = "Łącki", 7 | role = c("aut","cre","cph"), 8 | email = "matteo.lacki@gmail.com", 9 | comment = c(ORCID = "0000-0001-7415-4748")), 10 | person(given = "Michał Piotr", 11 | family = "Startek", 12 | role = c("aut","cph"), 13 | email="michal.startek@mimuw.edu.pl", 14 | comment=c(ORCID="0000-0001-5227-3447")) 15 | ) 16 | Maintainer: Mateusz Krzysztof Łącki 17 | Description: Access 'timsTOF' mass spectrometry data, as described (after registering), using the 'OpenTIMS' C++ reader and save all into 'data.tables'. 18 | License: GPL-3 19 | Encoding: UTF-8 20 | Roxygen: list(markdown = TRUE) 21 | RoxygenNote: 7.1.1 22 | Depends: 23 | R (>= 3.0.0) 24 | Imports: 25 | opentimsr, 26 | data.table, 27 | methods 28 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | TimsR is released under the terms of GNU GPL v3 licence, as 2 | published by the Free Software Foundation. Full text below. 3 | If you require other licensing terms please contact the authors. 4 | 5 | ============================================================ 6 | 7 | 8 | GNU GENERAL PUBLIC LICENSE 9 | Version 3, 29 June 2007 10 | 11 | Copyright (C) 2007 Free Software Foundation, Inc. 12 | Everyone is permitted to copy and distribute verbatim copies 13 | of this license document, but changing it is not allowed. 14 | 15 | Preamble 16 | 17 | The GNU General Public License is a free, copyleft license for 18 | software and other kinds of works. 19 | 20 | The licenses for most software and other practical works are designed 21 | to take away your freedom to share and change the works. By contrast, 22 | the GNU General Public License is intended to guarantee your freedom to 23 | share and change all versions of a program--to make sure it remains free 24 | software for all its users. We, the Free Software Foundation, use the 25 | GNU General Public License for most of our software; it applies also to 26 | any other work released this way by its authors. You can apply it to 27 | your programs, too. 28 | 29 | When we speak of free software, we are referring to freedom, not 30 | price. Our General Public Licenses are designed to make sure that you 31 | have the freedom to distribute copies of free software (and charge for 32 | them if you wish), that you receive source code or can get it if you 33 | want it, that you can change the software or use pieces of it in new 34 | free programs, and that you know you can do these things. 35 | 36 | To protect your rights, we need to prevent others from denying you 37 | these rights or asking you to surrender the rights. Therefore, you have 38 | certain responsibilities if you distribute copies of the software, or if 39 | you modify it: responsibilities to respect the freedom of others. 40 | 41 | For example, if you distribute copies of such a program, whether 42 | gratis or for a fee, you must pass on to the recipients the same 43 | freedoms that you received. You must make sure that they, too, receive 44 | or can get the source code. And you must show them these terms so they 45 | know their rights. 46 | 47 | Developers that use the GNU GPL protect your rights with two steps: 48 | (1) assert copyright on the software, and (2) offer you this License 49 | giving you legal permission to copy, distribute and/or modify it. 50 | 51 | For the developers' and authors' protection, the GPL clearly explains 52 | that there is no warranty for this free software. For both users' and 53 | authors' sake, the GPL requires that modified versions be marked as 54 | changed, so that their problems will not be attributed erroneously to 55 | authors of previous versions. 56 | 57 | Some devices are designed to deny users access to install or run 58 | modified versions of the software inside them, although the manufacturer 59 | can do so. This is fundamentally incompatible with the aim of 60 | protecting users' freedom to change the software. The systematic 61 | pattern of such abuse occurs in the area of products for individuals to 62 | use, which is precisely where it is most unacceptable. Therefore, we 63 | have designed this version of the GPL to prohibit the practice for those 64 | products. If such problems arise substantially in other domains, we 65 | stand ready to extend this provision to those domains in future versions 66 | of the GPL, as needed to protect the freedom of users. 67 | 68 | Finally, every program is threatened constantly by software patents. 69 | States should not allow patents to restrict development and use of 70 | software on general-purpose computers, but in those that do, we wish to 71 | avoid the special danger that patents applied to a free program could 72 | make it effectively proprietary. To prevent this, the GPL assures that 73 | patents cannot be used to render the program non-free. 74 | 75 | The precise terms and conditions for copying, distribution and 76 | modification follow. 77 | 78 | TERMS AND CONDITIONS 79 | 80 | 0. Definitions. 81 | 82 | "This License" refers to version 3 of the GNU General Public License. 83 | 84 | "Copyright" also means copyright-like laws that apply to other kinds of 85 | works, such as semiconductor masks. 86 | 87 | "The Program" refers to any copyrightable work licensed under this 88 | License. Each licensee is addressed as "you". "Licensees" and 89 | "recipients" may be individuals or organizations. 90 | 91 | To "modify" a work means to copy from or adapt all or part of the work 92 | in a fashion requiring copyright permission, other than the making of an 93 | exact copy. The resulting work is called a "modified version" of the 94 | earlier work or a work "based on" the earlier work. 95 | 96 | A "covered work" means either the unmodified Program or a work based 97 | on the Program. 98 | 99 | To "propagate" a work means to do anything with it that, without 100 | permission, would make you directly or secondarily liable for 101 | infringement under applicable copyright law, except executing it on a 102 | computer or modifying a private copy. Propagation includes copying, 103 | distribution (with or without modification), making available to the 104 | public, and in some countries other activities as well. 105 | 106 | To "convey" a work means any kind of propagation that enables other 107 | parties to make or receive copies. Mere interaction with a user through 108 | a computer network, with no transfer of a copy, is not conveying. 109 | 110 | An interactive user interface displays "Appropriate Legal Notices" 111 | to the extent that it includes a convenient and prominently visible 112 | feature that (1) displays an appropriate copyright notice, and (2) 113 | tells the user that there is no warranty for the work (except to the 114 | extent that warranties are provided), that licensees may convey the 115 | work under this License, and how to view a copy of this License. If 116 | the interface presents a list of user commands or options, such as a 117 | menu, a prominent item in the list meets this criterion. 118 | 119 | 1. Source Code. 120 | 121 | The "source code" for a work means the preferred form of the work 122 | for making modifications to it. "Object code" means any non-source 123 | form of a work. 124 | 125 | A "Standard Interface" means an interface that either is an official 126 | standard defined by a recognized standards body, or, in the case of 127 | interfaces specified for a particular programming language, one that 128 | is widely used among developers working in that language. 129 | 130 | The "System Libraries" of an executable work include anything, other 131 | than the work as a whole, that (a) is included in the normal form of 132 | packaging a Major Component, but which is not part of that Major 133 | Component, and (b) serves only to enable use of the work with that 134 | Major Component, or to implement a Standard Interface for which an 135 | implementation is available to the public in source code form. A 136 | "Major Component", in this context, means a major essential component 137 | (kernel, window system, and so on) of the specific operating system 138 | (if any) on which the executable work runs, or a compiler used to 139 | produce the work, or an object code interpreter used to run it. 140 | 141 | The "Corresponding Source" for a work in object code form means all 142 | the source code needed to generate, install, and (for an executable 143 | work) run the object code and to modify the work, including scripts to 144 | control those activities. However, it does not include the work's 145 | System Libraries, or general-purpose tools or generally available free 146 | programs which are used unmodified in performing those activities but 147 | which are not part of the work. For example, Corresponding Source 148 | includes interface definition files associated with source files for 149 | the work, and the source code for shared libraries and dynamically 150 | linked subprograms that the work is specifically designed to require, 151 | such as by intimate data communication or control flow between those 152 | subprograms and other parts of the work. 153 | 154 | The Corresponding Source need not include anything that users 155 | can regenerate automatically from other parts of the Corresponding 156 | Source. 157 | 158 | The Corresponding Source for a work in source code form is that 159 | same work. 160 | 161 | 2. Basic Permissions. 162 | 163 | All rights granted under this License are granted for the term of 164 | copyright on the Program, and are irrevocable provided the stated 165 | conditions are met. This License explicitly affirms your unlimited 166 | permission to run the unmodified Program. The output from running a 167 | covered work is covered by this License only if the output, given its 168 | content, constitutes a covered work. This License acknowledges your 169 | rights of fair use or other equivalent, as provided by copyright law. 170 | 171 | You may make, run and propagate covered works that you do not 172 | convey, without conditions so long as your license otherwise remains 173 | in force. You may convey covered works to others for the sole purpose 174 | of having them make modifications exclusively for you, or provide you 175 | with facilities for running those works, provided that you comply with 176 | the terms of this License in conveying all material for which you do 177 | not control copyright. Those thus making or running the covered works 178 | for you must do so exclusively on your behalf, under your direction 179 | and control, on terms that prohibit them from making any copies of 180 | your copyrighted material outside their relationship with you. 181 | 182 | Conveying under any other circumstances is permitted solely under 183 | the conditions stated below. Sublicensing is not allowed; section 10 184 | makes it unnecessary. 185 | 186 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 187 | 188 | No covered work shall be deemed part of an effective technological 189 | measure under any applicable law fulfilling obligations under article 190 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 191 | similar laws prohibiting or restricting circumvention of such 192 | measures. 193 | 194 | When you convey a covered work, you waive any legal power to forbid 195 | circumvention of technological measures to the extent such circumvention 196 | is effected by exercising rights under this License with respect to 197 | the covered work, and you disclaim any intention to limit operation or 198 | modification of the work as a means of enforcing, against the work's 199 | users, your or third parties' legal rights to forbid circumvention of 200 | technological measures. 201 | 202 | 4. Conveying Verbatim Copies. 203 | 204 | You may convey verbatim copies of the Program's source code as you 205 | receive it, in any medium, provided that you conspicuously and 206 | appropriately publish on each copy an appropriate copyright notice; 207 | keep intact all notices stating that this License and any 208 | non-permissive terms added in accord with section 7 apply to the code; 209 | keep intact all notices of the absence of any warranty; and give all 210 | recipients a copy of this License along with the Program. 211 | 212 | You may charge any price or no price for each copy that you convey, 213 | and you may offer support or warranty protection for a fee. 214 | 215 | 5. Conveying Modified Source Versions. 216 | 217 | You may convey a work based on the Program, or the modifications to 218 | produce it from the Program, in the form of source code under the 219 | terms of section 4, provided that you also meet all of these conditions: 220 | 221 | a) The work must carry prominent notices stating that you modified 222 | it, and giving a relevant date. 223 | 224 | b) The work must carry prominent notices stating that it is 225 | released under this License and any conditions added under section 226 | 7. This requirement modifies the requirement in section 4 to 227 | "keep intact all notices". 228 | 229 | c) You must license the entire work, as a whole, under this 230 | License to anyone who comes into possession of a copy. This 231 | License will therefore apply, along with any applicable section 7 232 | additional terms, to the whole of the work, and all its parts, 233 | regardless of how they are packaged. This License gives no 234 | permission to license the work in any other way, but it does not 235 | invalidate such permission if you have separately received it. 236 | 237 | d) If the work has interactive user interfaces, each must display 238 | Appropriate Legal Notices; however, if the Program has interactive 239 | interfaces that do not display Appropriate Legal Notices, your 240 | work need not make them do so. 241 | 242 | A compilation of a covered work with other separate and independent 243 | works, which are not by their nature extensions of the covered work, 244 | and which are not combined with it such as to form a larger program, 245 | in or on a volume of a storage or distribution medium, is called an 246 | "aggregate" if the compilation and its resulting copyright are not 247 | used to limit the access or legal rights of the compilation's users 248 | beyond what the individual works permit. Inclusion of a covered work 249 | in an aggregate does not cause this License to apply to the other 250 | parts of the aggregate. 251 | 252 | 6. Conveying Non-Source Forms. 253 | 254 | You may convey a covered work in object code form under the terms 255 | of sections 4 and 5, provided that you also convey the 256 | machine-readable Corresponding Source under the terms of this License, 257 | in one of these ways: 258 | 259 | a) Convey the object code in, or embodied in, a physical product 260 | (including a physical distribution medium), accompanied by the 261 | Corresponding Source fixed on a durable physical medium 262 | customarily used for software interchange. 263 | 264 | b) Convey the object code in, or embodied in, a physical product 265 | (including a physical distribution medium), accompanied by a 266 | written offer, valid for at least three years and valid for as 267 | long as you offer spare parts or customer support for that product 268 | model, to give anyone who possesses the object code either (1) a 269 | copy of the Corresponding Source for all the software in the 270 | product that is covered by this License, on a durable physical 271 | medium customarily used for software interchange, for a price no 272 | more than your reasonable cost of physically performing this 273 | conveying of source, or (2) access to copy the 274 | Corresponding Source from a network server at no charge. 275 | 276 | c) Convey individual copies of the object code with a copy of the 277 | written offer to provide the Corresponding Source. This 278 | alternative is allowed only occasionally and noncommercially, and 279 | only if you received the object code with such an offer, in accord 280 | with subsection 6b. 281 | 282 | d) Convey the object code by offering access from a designated 283 | place (gratis or for a charge), and offer equivalent access to the 284 | Corresponding Source in the same way through the same place at no 285 | further charge. You need not require recipients to copy the 286 | Corresponding Source along with the object code. If the place to 287 | copy the object code is a network server, the Corresponding Source 288 | may be on a different server (operated by you or a third party) 289 | that supports equivalent copying facilities, provided you maintain 290 | clear directions next to the object code saying where to find the 291 | Corresponding Source. Regardless of what server hosts the 292 | Corresponding Source, you remain obligated to ensure that it is 293 | available for as long as needed to satisfy these requirements. 294 | 295 | e) Convey the object code using peer-to-peer transmission, provided 296 | you inform other peers where the object code and Corresponding 297 | Source of the work are being offered to the general public at no 298 | charge under subsection 6d. 299 | 300 | A separable portion of the object code, whose source code is excluded 301 | from the Corresponding Source as a System Library, need not be 302 | included in conveying the object code work. 303 | 304 | A "User Product" is either (1) a "consumer product", which means any 305 | tangible personal property which is normally used for personal, family, 306 | or household purposes, or (2) anything designed or sold for incorporation 307 | into a dwelling. In determining whether a product is a consumer product, 308 | doubtful cases shall be resolved in favor of coverage. For a particular 309 | product received by a particular user, "normally used" refers to a 310 | typical or common use of that class of product, regardless of the status 311 | of the particular user or of the way in which the particular user 312 | actually uses, or expects or is expected to use, the product. A product 313 | is a consumer product regardless of whether the product has substantial 314 | commercial, industrial or non-consumer uses, unless such uses represent 315 | the only significant mode of use of the product. 316 | 317 | "Installation Information" for a User Product means any methods, 318 | procedures, authorization keys, or other information required to install 319 | and execute modified versions of a covered work in that User Product from 320 | a modified version of its Corresponding Source. The information must 321 | suffice to ensure that the continued functioning of the modified object 322 | code is in no case prevented or interfered with solely because 323 | modification has been made. 324 | 325 | If you convey an object code work under this section in, or with, or 326 | specifically for use in, a User Product, and the conveying occurs as 327 | part of a transaction in which the right of possession and use of the 328 | User Product is transferred to the recipient in perpetuity or for a 329 | fixed term (regardless of how the transaction is characterized), the 330 | Corresponding Source conveyed under this section must be accompanied 331 | by the Installation Information. But this requirement does not apply 332 | if neither you nor any third party retains the ability to install 333 | modified object code on the User Product (for example, the work has 334 | been installed in ROM). 335 | 336 | The requirement to provide Installation Information does not include a 337 | requirement to continue to provide support service, warranty, or updates 338 | for a work that has been modified or installed by the recipient, or for 339 | the User Product in which it has been modified or installed. Access to a 340 | network may be denied when the modification itself materially and 341 | adversely affects the operation of the network or violates the rules and 342 | protocols for communication across the network. 343 | 344 | Corresponding Source conveyed, and Installation Information provided, 345 | in accord with this section must be in a format that is publicly 346 | documented (and with an implementation available to the public in 347 | source code form), and must require no special password or key for 348 | unpacking, reading or copying. 349 | 350 | 7. Additional Terms. 351 | 352 | "Additional permissions" are terms that supplement the terms of this 353 | License by making exceptions from one or more of its conditions. 354 | Additional permissions that are applicable to the entire Program shall 355 | be treated as though they were included in this License, to the extent 356 | that they are valid under applicable law. If additional permissions 357 | apply only to part of the Program, that part may be used separately 358 | under those permissions, but the entire Program remains governed by 359 | this License without regard to the additional permissions. 360 | 361 | When you convey a copy of a covered work, you may at your option 362 | remove any additional permissions from that copy, or from any part of 363 | it. (Additional permissions may be written to require their own 364 | removal in certain cases when you modify the work.) You may place 365 | additional permissions on material, added by you to a covered work, 366 | for which you have or can give appropriate copyright permission. 367 | 368 | Notwithstanding any other provision of this License, for material you 369 | add to a covered work, you may (if authorized by the copyright holders of 370 | that material) supplement the terms of this License with terms: 371 | 372 | a) Disclaiming warranty or limiting liability differently from the 373 | terms of sections 15 and 16 of this License; or 374 | 375 | b) Requiring preservation of specified reasonable legal notices or 376 | author attributions in that material or in the Appropriate Legal 377 | Notices displayed by works containing it; or 378 | 379 | c) Prohibiting misrepresentation of the origin of that material, or 380 | requiring that modified versions of such material be marked in 381 | reasonable ways as different from the original version; or 382 | 383 | d) Limiting the use for publicity purposes of names of licensors or 384 | authors of the material; or 385 | 386 | e) Declining to grant rights under trademark law for use of some 387 | trade names, trademarks, or service marks; or 388 | 389 | f) Requiring indemnification of licensors and authors of that 390 | material by anyone who conveys the material (or modified versions of 391 | it) with contractual assumptions of liability to the recipient, for 392 | any liability that these contractual assumptions directly impose on 393 | those licensors and authors. 394 | 395 | All other non-permissive additional terms are considered "further 396 | restrictions" within the meaning of section 10. If the Program as you 397 | received it, or any part of it, contains a notice stating that it is 398 | governed by this License along with a term that is a further 399 | restriction, you may remove that term. If a license document contains 400 | a further restriction but permits relicensing or conveying under this 401 | License, you may add to a covered work material governed by the terms 402 | of that license document, provided that the further restriction does 403 | not survive such relicensing or conveying. 404 | 405 | If you add terms to a covered work in accord with this section, you 406 | must place, in the relevant source files, a statement of the 407 | additional terms that apply to those files, or a notice indicating 408 | where to find the applicable terms. 409 | 410 | Additional terms, permissive or non-permissive, may be stated in the 411 | form of a separately written license, or stated as exceptions; 412 | the above requirements apply either way. 413 | 414 | 8. Termination. 415 | 416 | You may not propagate or modify a covered work except as expressly 417 | provided under this License. Any attempt otherwise to propagate or 418 | modify it is void, and will automatically terminate your rights under 419 | this License (including any patent licenses granted under the third 420 | paragraph of section 11). 421 | 422 | However, if you cease all violation of this License, then your 423 | license from a particular copyright holder is reinstated (a) 424 | provisionally, unless and until the copyright holder explicitly and 425 | finally terminates your license, and (b) permanently, if the copyright 426 | holder fails to notify you of the violation by some reasonable means 427 | prior to 60 days after the cessation. 428 | 429 | Moreover, your license from a particular copyright holder is 430 | reinstated permanently if the copyright holder notifies you of the 431 | violation by some reasonable means, this is the first time you have 432 | received notice of violation of this License (for any work) from that 433 | copyright holder, and you cure the violation prior to 30 days after 434 | your receipt of the notice. 435 | 436 | Termination of your rights under this section does not terminate the 437 | licenses of parties who have received copies or rights from you under 438 | this License. If your rights have been terminated and not permanently 439 | reinstated, you do not qualify to receive new licenses for the same 440 | material under section 10. 441 | 442 | 9. Acceptance Not Required for Having Copies. 443 | 444 | You are not required to accept this License in order to receive or 445 | run a copy of the Program. Ancillary propagation of a covered work 446 | occurring solely as a consequence of using peer-to-peer transmission 447 | to receive a copy likewise does not require acceptance. However, 448 | nothing other than this License grants you permission to propagate or 449 | modify any covered work. These actions infringe copyright if you do 450 | not accept this License. Therefore, by modifying or propagating a 451 | covered work, you indicate your acceptance of this License to do so. 452 | 453 | 10. Automatic Licensing of Downstream Recipients. 454 | 455 | Each time you convey a covered work, the recipient automatically 456 | receives a license from the original licensors, to run, modify and 457 | propagate that work, subject to this License. You are not responsible 458 | for enforcing compliance by third parties with this License. 459 | 460 | An "entity transaction" is a transaction transferring control of an 461 | organization, or substantially all assets of one, or subdividing an 462 | organization, or merging organizations. If propagation of a covered 463 | work results from an entity transaction, each party to that 464 | transaction who receives a copy of the work also receives whatever 465 | licenses to the work the party's predecessor in interest had or could 466 | give under the previous paragraph, plus a right to possession of the 467 | Corresponding Source of the work from the predecessor in interest, if 468 | the predecessor has it or can get it with reasonable efforts. 469 | 470 | You may not impose any further restrictions on the exercise of the 471 | rights granted or affirmed under this License. For example, you may 472 | not impose a license fee, royalty, or other charge for exercise of 473 | rights granted under this License, and you may not initiate litigation 474 | (including a cross-claim or counterclaim in a lawsuit) alleging that 475 | any patent claim is infringed by making, using, selling, offering for 476 | sale, or importing the Program or any portion of it. 477 | 478 | 11. Patents. 479 | 480 | A "contributor" is a copyright holder who authorizes use under this 481 | License of the Program or a work on which the Program is based. The 482 | work thus licensed is called the contributor's "contributor version". 483 | 484 | A contributor's "essential patent claims" are all patent claims 485 | owned or controlled by the contributor, whether already acquired or 486 | hereafter acquired, that would be infringed by some manner, permitted 487 | by this License, of making, using, or selling its contributor version, 488 | but do not include claims that would be infringed only as a 489 | consequence of further modification of the contributor version. For 490 | purposes of this definition, "control" includes the right to grant 491 | patent sublicenses in a manner consistent with the requirements of 492 | this License. 493 | 494 | Each contributor grants you a non-exclusive, worldwide, royalty-free 495 | patent license under the contributor's essential patent claims, to 496 | make, use, sell, offer for sale, import and otherwise run, modify and 497 | propagate the contents of its contributor version. 498 | 499 | In the following three paragraphs, a "patent license" is any express 500 | agreement or commitment, however denominated, not to enforce a patent 501 | (such as an express permission to practice a patent or covenant not to 502 | sue for patent infringement). To "grant" such a patent license to a 503 | party means to make such an agreement or commitment not to enforce a 504 | patent against the party. 505 | 506 | If you convey a covered work, knowingly relying on a patent license, 507 | and the Corresponding Source of the work is not available for anyone 508 | to copy, free of charge and under the terms of this License, through a 509 | publicly available network server or other readily accessible means, 510 | then you must either (1) cause the Corresponding Source to be so 511 | available, or (2) arrange to deprive yourself of the benefit of the 512 | patent license for this particular work, or (3) arrange, in a manner 513 | consistent with the requirements of this License, to extend the patent 514 | license to downstream recipients. "Knowingly relying" means you have 515 | actual knowledge that, but for the patent license, your conveying the 516 | covered work in a country, or your recipient's use of the covered work 517 | in a country, would infringe one or more identifiable patents in that 518 | country that you have reason to believe are valid. 519 | 520 | If, pursuant to or in connection with a single transaction or 521 | arrangement, you convey, or propagate by procuring conveyance of, a 522 | covered work, and grant a patent license to some of the parties 523 | receiving the covered work authorizing them to use, propagate, modify 524 | or convey a specific copy of the covered work, then the patent license 525 | you grant is automatically extended to all recipients of the covered 526 | work and works based on it. 527 | 528 | A patent license is "discriminatory" if it does not include within 529 | the scope of its coverage, prohibits the exercise of, or is 530 | conditioned on the non-exercise of one or more of the rights that are 531 | specifically granted under this License. You may not convey a covered 532 | work if you are a party to an arrangement with a third party that is 533 | in the business of distributing software, under which you make payment 534 | to the third party based on the extent of your activity of conveying 535 | the work, and under which the third party grants, to any of the 536 | parties who would receive the covered work from you, a discriminatory 537 | patent license (a) in connection with copies of the covered work 538 | conveyed by you (or copies made from those copies), or (b) primarily 539 | for and in connection with specific products or compilations that 540 | contain the covered work, unless you entered into that arrangement, 541 | or that patent license was granted, prior to 28 March 2007. 542 | 543 | Nothing in this License shall be construed as excluding or limiting 544 | any implied license or other defenses to infringement that may 545 | otherwise be available to you under applicable patent law. 546 | 547 | 12. No Surrender of Others' Freedom. 548 | 549 | If conditions are imposed on you (whether by court order, agreement or 550 | otherwise) that contradict the conditions of this License, they do not 551 | excuse you from the conditions of this License. If you cannot convey a 552 | covered work so as to satisfy simultaneously your obligations under this 553 | License and any other pertinent obligations, then as a consequence you may 554 | not convey it at all. For example, if you agree to terms that obligate you 555 | to collect a royalty for further conveying from those to whom you convey 556 | the Program, the only way you could satisfy both those terms and this 557 | License would be to refrain entirely from conveying the Program. 558 | 559 | 13. Use with the GNU Affero General Public License. 560 | 561 | Notwithstanding any other provision of this License, you have 562 | permission to link or combine any covered work with a work licensed 563 | under version 3 of the GNU Affero General Public License into a single 564 | combined work, and to convey the resulting work. The terms of this 565 | License will continue to apply to the part which is the covered work, 566 | but the special requirements of the GNU Affero General Public License, 567 | section 13, concerning interaction through a network will apply to the 568 | combination as such. 569 | 570 | 14. Revised Versions of this License. 571 | 572 | The Free Software Foundation may publish revised and/or new versions of 573 | the GNU General Public License from time to time. Such new versions will 574 | be similar in spirit to the present version, but may differ in detail to 575 | address new problems or concerns. 576 | 577 | Each version is given a distinguishing version number. If the 578 | Program specifies that a certain numbered version of the GNU General 579 | Public License "or any later version" applies to it, you have the 580 | option of following the terms and conditions either of that numbered 581 | version or of any later version published by the Free Software 582 | Foundation. If the Program does not specify a version number of the 583 | GNU General Public License, you may choose any version ever published 584 | by the Free Software Foundation. 585 | 586 | If the Program specifies that a proxy can decide which future 587 | versions of the GNU General Public License can be used, that proxy's 588 | public statement of acceptance of a version permanently authorizes you 589 | to choose that version for the Program. 590 | 591 | Later license versions may give you additional or different 592 | permissions. However, no additional obligations are imposed on any 593 | author or copyright holder as a result of your choosing to follow a 594 | later version. 595 | 596 | 15. Disclaimer of Warranty. 597 | 598 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 599 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 600 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 601 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 602 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 603 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 604 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 605 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 606 | 607 | 16. Limitation of Liability. 608 | 609 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 610 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 611 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 612 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 613 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 614 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 615 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 616 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 617 | SUCH DAMAGES. 618 | 619 | 17. Interpretation of Sections 15 and 16. 620 | 621 | If the disclaimer of warranty and limitation of liability provided 622 | above cannot be given local legal effect according to their terms, 623 | reviewing courts shall apply local law that most closely approximates 624 | an absolute waiver of all civil liability in connection with the 625 | Program, unless a warranty or assumption of liability accompanies a 626 | copy of the Program in return for a fee. 627 | 628 | END OF TERMS AND CONDITIONS 629 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(MS1) 4 | export(TimsR) 5 | export(cleanMem) 6 | export(download_bruker_proprietary_code) 7 | export(intensity_per_frame) 8 | export(min_max_measurements) 9 | export(peaks_per_frame_cnts) 10 | export(plot_TIC) 11 | export(query) 12 | export(retention_times) 13 | export(rt_query) 14 | export(setup_bruker_so) 15 | export(table2dt) 16 | export(tables_names) 17 | export(tdf.tables) 18 | exportClasses(TimsR) 19 | exportMethods("[") 20 | importFrom(data.table,as.data.table) 21 | importFrom(data.table,setDT) 22 | importFrom(graphics,legend) 23 | importFrom(graphics,lines) 24 | importFrom(graphics,plot) 25 | importFrom(methods,callNextMethod) 26 | importFrom(methods,new) 27 | importFrom(opentimsr,MS1) 28 | importFrom(opentimsr,OpenTIMS) 29 | importFrom(opentimsr,download_bruker_proprietary_code) 30 | importFrom(opentimsr,peaks_per_frame_cnts) 31 | importFrom(opentimsr,query) 32 | importFrom(opentimsr,retention_times) 33 | importFrom(opentimsr,setup_bruker_so) 34 | importFrom(opentimsr,table2df) 35 | importFrom(opentimsr,tables_names) 36 | -------------------------------------------------------------------------------- /R/timsr.R: -------------------------------------------------------------------------------- 1 | # * TimsR: a fully open-source library for opening Bruker's TimsTOF data files. 2 | # * Copyright (C) 2020 Michał Startek and Mateusz Łącki 3 | # * 4 | # * This program is free software: you can redistribute it and/or modify 5 | # * it under the terms of the GNU General Public License, version 3 only, 6 | # * as published by the Free Software Foundation. 7 | # * 8 | # * This program is distributed in the hope that it will be useful, 9 | # * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # * GNU General Public License for more details. 12 | # * 13 | # * You should have received a copy of the GNU General Public License 14 | # * along with this program. If not, see . 15 | 16 | 17 | #' Advanced TimsTOF data accessor. 18 | #' 19 | #' S4 class that facilitates data queries for TimsTOF data. 20 | #' 21 | #' @importFrom opentimsr OpenTIMS 22 | #' @export 23 | setClass("TimsR", contains="OpenTIMS") 24 | 25 | 26 | all_columns = c('frame','scan','tof','intensity','mz','inv_ion_mobility','retention_time') 27 | 28 | 29 | #' Get TimsR data accessor. 30 | #' 31 | #' @param path.d Path to the TimsTOF '*.d' folder containing the data (requires the folder to contain only 'analysis.tdf' and 'analysis.tdf_bin'). 32 | #' @examples 33 | #' \dontrun{ 34 | #' D = TimsR(path_to_.d_folder) 35 | #' D[1] # First frame. 36 | #' } 37 | #' @importFrom opentimsr OpenTIMS 38 | #' @importFrom methods new 39 | #' @export 40 | #' @return instance of TimsR class that represents raw data 41 | TimsR = function(path.d){ 42 | new("TimsR", OpenTIMS(path.d)) 43 | } 44 | 45 | #' Get border values for measurements. 46 | #' 47 | #' Get the min-max values of the measured variables (except for TOFs, that would require iteration through data rather than parsing metadata). 48 | #' 49 | #' @param timsr Instance of TimsR. 50 | #' @return data.frame Limits of individual extracted quantities. 51 | #' @export 52 | #' @examples 53 | #' \dontrun{ 54 | #' D = TimsR('path/to/your/folder.d') 55 | #' min_max_measurements(D) # this gives a small data-frame with min and max values. 56 | #' } 57 | min_max_measurements = function(timsr) opentimsr::min_max_measurements(timsr) 58 | 59 | 60 | #' Get some frames of data. 61 | #' 62 | #' @param x OpenTIMS data instance. 63 | #' @param i An array of nonzero indices to extract. 64 | #' @importFrom data.table setDT 65 | #' @export 66 | #' @examples 67 | #' \dontrun{ 68 | #' D = TimsR('path/to/your/folder.d') 69 | #' print(head(D[10])) 70 | #' print(head(D[10:100])) 71 | #' } 72 | #' @return data.table 73 | setMethod("[", 74 | signature(x = "TimsR", i = "ANY"), 75 | function(x, i){ 76 | dt = callNextMethod(x, i) 77 | data.table::setDT(dt) 78 | dt 79 | }) 80 | 81 | 82 | #' Extract tables from sqlite database analysis.tdf. 83 | #' 84 | #' Export a table from sqlite. 85 | #' 86 | #' @param timsr Instance of TimsR 87 | #' @param names Names to extract from the sqlite database. 88 | #' @export 89 | #' @importFrom opentimsr table2df 90 | #' @importFrom data.table as.data.table 91 | #' @examples 92 | #' \dontrun{ 93 | #' D = TimsR('path/to/your/folder.d') 94 | #' print(head(table2dt(D, "Frames"))) # Extract table "Frames". 95 | #' } 96 | #' @return data.table 97 | table2dt = function(timsr, names) data.table::as.data.table(opentimsr::table2df(timsr, names)) 98 | 99 | 100 | #' Extract tables from sqlite database analysis.tdf. 101 | #' 102 | #' @param timsr Instance of TimsR 103 | #' @return character, names of tables. 104 | #' @export 105 | #' @importFrom opentimsr tables_names 106 | #' @examples 107 | #' \dontrun{ 108 | #' D = TimsR('path/to/your/folder.d') 109 | #' print(tables_names(D)) 110 | #' } 111 | tables_names = function(timsr) opentimsr::tables_names(timsr) 112 | 113 | 114 | #' Explore the contentents of the sqlite .tdf database. 115 | #' 116 | #' @param timsr Instance of TimsR 117 | #' @return List of data.tables filled with data from 'analysis.tdf'. 118 | #' @export 119 | #' @examples 120 | #' \dontrun{ 121 | #' D = TimsR('path/to/your/folder.d') 122 | #' print(tdf.tables(D)) 123 | #' } 124 | tdf.tables = function(timsr){ 125 | .table_names = tables_names(timsr) 126 | res = lapply(.table_names, table2dt, timsr=timsr) 127 | names(res) = .table_names 128 | res 129 | } 130 | 131 | 132 | 133 | #' Get MS1 frame numbers. 134 | #' 135 | #' @param timsr Instance of TimsR 136 | #' @return Numbers of frames corresponding to MS1, i.e. precursor ions. 137 | #' @export 138 | #' @importFrom opentimsr MS1 139 | #' @examples 140 | #' \dontrun{ 141 | #' D = TimsR('path/to/your/folder.d') 142 | #' print(MS1(D)) 143 | #' } 144 | MS1 = function(timsr) opentimsr::MS1(timsr) 145 | 146 | 147 | #' Get the number of peaks per frame. 148 | #' 149 | #' @param timsr Instance of TimsR. 150 | #' @return Number of peaks in each frame. 151 | #' @export 152 | #' @importFrom opentimsr peaks_per_frame_cnts 153 | #' @examples 154 | #' \dontrun{ 155 | #' D = TimsR('path/to/your/folder.d') 156 | #' print(peaks_per_frame_cnts(D)) 157 | #' } 158 | peaks_per_frame_cnts = function(timsr) opentimsr::peaks_per_frame_cnts(timsr) 159 | 160 | 161 | #' Get the retention time for each frame. 162 | #' 163 | #' @param timsr Instance of TimsR. 164 | #' @return Retention times corresponding to each frame. 165 | #' @export 166 | #' @importFrom opentimsr retention_times 167 | #' @examples 168 | #' \dontrun{ 169 | #' D = TimsR('path/to/your/folder.d') 170 | #' print(retention_times(D)) 171 | #' } 172 | retention_times = function(timsr) opentimsr::retention_times(timsr) 173 | 174 | 175 | #' Query for raw data. 176 | #' 177 | #' Get the raw data from Bruker's 'tdf_bin' format. 178 | #' Defaults to both raw data ('frame','scan','tof','intensity') and its tranformations into physical units ('mz','inv_ion_mobility','retention_time'). 179 | #' 180 | #' @param timsr Instance of TimsR. 181 | #' @param frames Vector of frame numbers to extract. 182 | #' @param columns Vector of columns to extract. Defaults to all columns. 183 | #' @return data.frame with selected columns. 184 | #' @importFrom data.table setDT 185 | #' @importFrom opentimsr query 186 | #' @export 187 | #' @examples 188 | #' \dontrun{ 189 | #' D = TimsR('path/to/your/folder.d') 190 | #' print(query(D, c(1,20, 53)) # extract all columns 191 | #' print(query(D, c(1,20, 53), columns=c('scan','intensity')) # only 'scan' and 'intensity' 192 | #' } 193 | query = function(timsr, 194 | frames, 195 | columns=all_columns){ 196 | dt = opentimsr::query(timsr, frames, columns) 197 | data.table::setDT(dt) 198 | dt 199 | } 200 | 201 | 202 | #' Get some frames of data. 203 | #' 204 | #' @param x OpenTIMS data instance. 205 | #' @param i An array of nonzero frame numbers to extract. 206 | #' @param j A vector of strings with column names to extract. 207 | #' @importFrom data.table setDT 208 | #' @importFrom methods callNextMethod 209 | #' @examples 210 | #' \dontrun{ 211 | #' D = TimsR('path/to/your/folder.d') 212 | #' all_cols = c('frame','scan','tof','intensity', 213 | #' 'mz','inv_ion_mobility','retention_time') 214 | #' print(D[c(1,20, 53), all_cols] 215 | #' # extracted all columns 216 | #' 217 | #' print(D[c(1,20, 53), c('scan','intensity')] 218 | #' # only 'scan' and 'intensity' 219 | #' } 220 | #' @return data.table 221 | setMethod("[", 222 | signature(x = "TimsR", i = "ANY", j="character"), 223 | function(x, i, j) query(x, i, j) 224 | ) 225 | 226 | 227 | get_left_frame = function(x,y) ifelse(x > y[length(y)], NA, findInterval(x, y, left.open=T) + 1) 228 | 229 | get_right_frame = function(x,y) ifelse(x < y[1], NA, findInterval(x, y, left.open=F)) 230 | 231 | 232 | #' Get the retention time for each frame. 233 | #' 234 | #' @param timsr Instance of TimsR 235 | #' @param min_retention_time Lower boundry on retention time. 236 | #' @param max_retention_time Upper boundry on retention time. 237 | #' @param columns Vector of columns to extract. Defaults to all columns. 238 | #' @return data.frame with selected columns. 239 | #' @importFrom data.table setDT 240 | #' @importFrom opentimsr retention_times 241 | #' @export 242 | #' @examples 243 | #' \dontrun{ 244 | #' D = TimsR('path/to/your/folder.d') 245 | #' print(query_slice(D, 10, 200, 4)) # extract every fourth frame between 10 and 200. 246 | #' print(query_slice(D, 10, 200, 4, columns=c('scan','intensity')) # only 'scan' and 'intensity' 247 | #' } 248 | rt_query = function(timsr, 249 | min_retention_time, 250 | max_retention_time, 251 | columns=all_columns){ 252 | 253 | RTS = opentimsr::retention_times(timsr) 254 | 255 | min_frame = get_left_frame(min_retention_time, RTS) 256 | max_frame = get_right_frame(max_retention_time, RTS) 257 | 258 | if(is.na(min_frame) | is.na(max_frame)) 259 | stop("The [min_retention_time,max_retention_time] interval does not hold any data.") 260 | 261 | query(timsr, min_frame:max_frame, columns) 262 | } 263 | 264 | 265 | 266 | #' Clean memory. 267 | #' 268 | #' Run garbage collection, by default - 10 times. 269 | #' 270 | #' Check 271 | #' @export 272 | #' @param times Number of times to run garbage collection. 273 | #' @return No return value, called for side effects. 274 | #' @examples 275 | #' \dontrun{ 276 | #' cleanMem() 277 | #' } 278 | cleanMem = function(times=10) { for (i in 1:times) gc() } 279 | 280 | 281 | #' Get Bruker's code needed for running proprietary time of flight to mass over charge and scan to drift time conversion. 282 | #' 283 | #' By using this function you aggree to terms of license precised in "https://github.com/MatteoLacki/opentims_bruker_bridge". 284 | #' The conversion, due to independent code-base restrictions, are possible only on Linux and Windows operating systems. 285 | #' Works on full open-source solution are on the way. 286 | #' 287 | #' @param target.folder Folder where to store the 'dll' or 'so' file. 288 | #' @param net_url The url with location of all files. 289 | #' @param mode Which mode to use when downloading a file? 290 | #' @param ... Other parameters to 'download.file'. 291 | #' @return character, path to the output 'timsdata.dll' on Windows and 'libtimsdata.so' on Linux. 292 | #' @importFrom opentimsr download_bruker_proprietary_code 293 | #' @export 294 | #' @examples 295 | #' \dontrun{ 296 | #' download_bruker_proprietary_code("your/prefered/destination/folder") 297 | #' } 298 | download_bruker_proprietary_code = function( 299 | target.folder, 300 | net_url=paste0("https://github.com/MatteoLacki/opentims_bruker_bridge/", 301 | "raw/main/opentims_bruker_bridge/"), 302 | mode="wb", 303 | ...) opentimsr::download_bruker_proprietary_code( 304 | target.folder, 305 | net_url, 306 | mode, 307 | ...) 308 | 309 | 310 | 311 | #' Dynamically link Bruker's DLL to enable tof-mz and scan-inv_ion_mobility conversion. 312 | #' 313 | #' By using this function you aggree to terms of license precised in "https://github.com/MatteoLacki/opentims_bruker_bridge". 314 | #' The conversion, due to independent code-base restrictions, are possible only on Linux and Windows operating systems. 315 | #' Works on full open-source solution are on the way. 316 | #' 317 | #' @param path Path to the 'libtimsdata.so' on Linux or 'timsdata.dll' on Windows, as produced by 'download_bruker_proprietary_code'. 318 | #' @export 319 | #' @importFrom opentimsr setup_bruker_so 320 | #' @examples 321 | #' \dontrun{ 322 | #' so_path = download_bruker_proprietary_code("your/prefered/destination/folder") 323 | #' setup_bruker_so(so_path) 324 | #' } 325 | #' @return No return value, called for side effects. 326 | setup_bruker_so = function(path) opentimsr::setup_bruker_so(path) 327 | 328 | 329 | #' Get sum of intensity per each frame (retention time). 330 | #' 331 | #' @param timsr Instance of TimsR 332 | #' @param recalibrated Use Bruker recalibrated total intensities or calculate them from scratch with OpenTIMS? 333 | #' @export 334 | #' @examples 335 | #' \dontrun{ 336 | #' D = TimsR('path/to/your/folder.d') 337 | #' print(intensity_per_frame(D)) 338 | #' print(intensity_per_frame(D, recalibrated=FALSE)) 339 | #' } 340 | #' @return integer vector: total intensity per each frame. 341 | intensity_per_frame = function(timsr, recalibrated=TRUE){ 342 | if(recalibrated){ 343 | frames = table2dt(timsr,'Frames') 344 | .intensity_per_frame = frames$Frames.SummedIntensities 345 | } else { 346 | .intensity_per_frame = sapply( 347 | timsr@min_frame:timsr@max_frame, 348 | function(fr) sum(timsr[fr, c('intensity')]$intensity)) 349 | } 350 | return(.intensity_per_frame) 351 | } 352 | 353 | 354 | #' Plot intensity per retention time. 355 | #' 356 | #' Plot will split 'MS1' and 'MS2'. 357 | #' 358 | #' @param timsr Instance of TimsR 359 | #' @param recalibrated Use Bruker recalibrated total intensities or calculate them from scratch with OpenTIMS? 360 | #' @export 361 | #' @importFrom graphics legend lines plot 362 | #' @examples 363 | #' \dontrun{ 364 | #' D = TimsR('path/to/your/folder.d') 365 | #' plot_TIC(D) 366 | #' plot_TIC(D, recalibrated=FALSE) 367 | #' } 368 | #' @return No return value, called for side effects. 369 | plot_TIC = function(timsr, recalibrated=TRUE){ 370 | I = intensity_per_frame(timsr, recalibrated) 371 | RT = retention_times(timsr) 372 | frames = table2dt(timsr, "Frames") 373 | .ms1_mask = frames$Frames.MsMsType == 0 374 | plot(RT[.ms1_mask], 375 | I[.ms1_mask], 376 | type='l', 377 | col='red', 378 | xlab='Retention Time', 379 | ylab='Intensity') 380 | lines(RT[!.ms1_mask], 381 | I[!.ms1_mask], 382 | type='l', 383 | col='blue') 384 | legend("topright", 385 | legend=c("MS1", "MS2"), 386 | col=c("red", "blue"), 387 | lty=c(1,1), 388 | cex=1.5) 389 | } 390 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TimsR 2 | 3 | A data science friendly data access to timsTOF Pro mass spectrometry data from R. 4 | 5 | ### Requirements 6 | 7 | TimsPy should work on Linux, Windows (sadly), and macOS. 8 | TimsPy is open-source, but as it uses OpenTIMS under the hood, it comes with similar restrictions concerning the time of flight to mass to charge and scan number to inverse ion mobility conversions [(check out for details here)](https://github.com/michalsta/opentims). 9 | 10 | 11 | ### What can you expect? 12 | 13 | Simple way to get data out of results collected with your Bruker timsTOF Pro from R. 14 | This definitely ain't no rocket science, but is pretty useful! 15 | The data is reported in stored in `data.table` objects, that are the only thing `R` has to actually work meaningfully with big data sets. 16 | Before using `TimsR`, it makes a lot of sense to [study this package](https://CRAN.R-project.org/package=data.table). 17 | A helpful cheatsheet is available [here](https://raw.githubusercontent.com/rstudio/cheatsheets/master/datatable.pdf). 18 | 19 | With that out of the way, it's all as easy as shown below: 20 | 21 | ```R 22 | library(timsr) 23 | 24 | path = 'path/to/your/data.d' 25 | 26 | # Do you want to have access only to 'frame', 'scan', 'time of flight', and 'intensity'? 27 | accept_Bruker_EULA_and_on_Windows_or_Linux = TRUE 28 | 29 | if(accept_Bruker_EULA_and_on_Windows_or_Linux){ 30 | folder_to_stode_priopriatary_code = "/home/matteo" 31 | path_to_bruker_dll = download_bruker_proprietary_code(folder_to_stode_priopriatary_code) 32 | setup_bruker_so(path_to_bruker_dll) 33 | all_columns = c('frame','scan','tof','intensity','mz','inv_ion_mobility','retention_time') 34 | } else { 35 | all_columns = c('frame','scan','tof','intensity','retention_time') 36 | } 37 | # NOTE: if you already did download the 'so' or 'dll', simply use 38 | # setup_bruker_so(path_to_bruker_dll) 39 | # directly with the proper path to it. 40 | 41 | D = TimsR(path) # get data handle 42 | 43 | print(D) 44 | print(length(D)) # The number of peaks. 45 | # 404183877 46 | 47 | 48 | # Get a data,frame with data from frames 1, 5, and 67. 49 | X = D[c(1,5,67), all_columns] 50 | print(X) 51 | # frame scan tof intensity mz inv_ion_mobility retention_time 52 | # 1: 1 33 312260 9 1174.6558 1.6011418 0.3264921 53 | # 2: 1 34 220720 9 733.4809 1.6000000 0.3264921 54 | # 3: 1 34 261438 9 916.9524 1.6000000 0.3264921 55 | # 4: 1 36 33072 9 152.3557 1.5977164 0.3264921 56 | # 5: 1 36 242110 9 827.3114 1.5977164 0.3264921 57 | # --- 58 | # 224733: 67 917 192745 51 619.2850 0.6007742 7.4056544 59 | # 224734: 67 917 201838 54 655.3439 0.6007742 7.4056544 60 | # 224735: 67 917 205954 19 672.0017 0.6007742 7.4056544 61 | # 224736: 67 917 236501 57 802.1606 0.6007742 7.4056544 62 | # 224737: 67 917 289480 95 1055.2037 0.6007742 7.4056544 63 | 64 | 65 | # Get a dict with each 10th frame, starting from frame 2, finishing on frame 1000. 66 | X = D[seq(2,1000,10), all_columns] 67 | # frame scan tof intensity mz inv_ion_mobility retention_time 68 | # 1: 2 33 97298 9 302.3477 1.6011418 0.4347063 69 | # 2: 2 33 310524 9 1165.3273 1.6011418 0.4347063 70 | # 3: 2 34 127985 9 391.9841 1.6000000 0.4347063 71 | # 4: 2 35 280460 9 1009.6751 1.5988582 0.4347063 72 | # 5: 2 37 329377 72 1268.6262 1.5965746 0.4347063 73 | # --- 74 | # 669553: 992 909 198994 9 643.9562 0.6097471 106.7102786 75 | # 669554: 992 909 282616 9 1020.4663 0.6097471 106.7102786 76 | # 669555: 992 912 143270 9 440.9670 0.6063821 106.7102786 77 | # 669556: 992 915 309328 9 1158.9221 0.6030173 106.7102786 78 | # 669557: 992 916 224410 9 749.2647 0.6018958 106.7102786 79 | 80 | 81 | 82 | # Get all MS1 frames 83 | # print(query(D, frames=MS1(D))) 84 | # ATTENTION: that's quite a lot of data!!! And R will first make a stupid copy, because it's bad. You might exceed your RAM. 85 | 86 | # Getting subset of columns: simply specify 'columns': 87 | D[c(1,5,67), c('scan','intensity')] 88 | # scan intensity 89 | # 1: 33 9 90 | # 2: 34 9 91 | # 3: 34 9 92 | # 4: 36 9 93 | # 5: 36 9 94 | # --- 95 | # 224733: 917 51 96 | # 224734: 917 54 97 | # 224735: 917 19 98 | # 224736: 917 57 99 | # 224737: 917 95 100 | # 101 | # this is also the only way to get data without accepting Bruker terms of service and on MacOS (for time being). 102 | # In that case, you can choose among columns: 103 | # c('frame','scan','tof','intensity','rt') 104 | 105 | # Not specifying columns defaults to extracting only the actaully stored raw data in t'analysis.tdf_raw' without their transformations: 106 | D[100] 107 | # frame scan tof intensity 108 | # 1: 100 35 389679 9 109 | # 2: 100 35 394578 9 110 | # 3: 100 37 78036 9 111 | # 4: 100 37 210934 9 112 | # 5: 100 37 211498 9 113 | # --- 114 | # 7281: 100 910 156846 9 115 | # 7282: 100 910 355234 9 116 | # 7283: 100 911 294204 9 117 | # 7284: 100 913 248788 9 118 | # 7285: 100 915 100120 120 119 | 120 | 121 | D[1:100] 122 | # frame scan tof intensity 123 | # 1: 1 33 312260 9 124 | # 2: 1 34 220720 9 125 | # 3: 1 34 261438 9 126 | # 4: 1 36 33072 9 127 | # 5: 1 36 242110 9 128 | # --- 129 | # 1633354: 100 910 156846 9 130 | # 1633355: 100 910 355234 9 131 | # 1633356: 100 911 294204 9 132 | # 1633357: 100 913 248788 9 133 | # 1633358: 100 915 100120 120 134 | 135 | 136 | # The frame lasts a convenient time unit that well suits chromatography peak elution. 137 | # What if you were interested instead in finding out which frames eluted in a given time 138 | # time of the experiment? 139 | # For this reasone, we have prepared a retention time based query: 140 | # suppose you are interested in all frames corresponding to all that eluted between 10 and 12 second of the experiment. 141 | pprint(rt_query(D, 10, 12)) 142 | # frame scan tof intensity mz inv_ion_mobility retention_time 143 | # 1: 92 33 361758 9 1456.2835 1.6011418 10.08690 144 | # 2: 92 36 65738 9 222.2822 1.5977164 10.08690 145 | # 3: 92 41 308330 9 1153.5909 1.5920078 10.08690 146 | # 4: 92 43 123618 9 378.5190 1.5897245 10.08690 147 | # 5: 92 48 65346 9 221.3651 1.5840168 10.08690 148 | # --- 149 | # 128130: 109 914 138760 65 426.2142 0.6041389 11.91001 150 | # 128131: 109 914 142129 69 437.2109 0.6041389 11.91001 151 | # 128132: 109 914 144566 58 445.2528 0.6041389 11.91001 152 | # 128133: 109 916 138933 91 426.7755 0.6018958 11.91001 153 | # 128134: 109 917 373182 9 1525.5765 0.6007742 11.91001 154 | 155 | 156 | # All MS1 frames, but one at a time: 157 | for(fr in MS1(D)) print(D[fr, all_columns]) 158 | # Of course, it's better to use lapply or mclapply to speed up things. 159 | 160 | # Extracting information from 'analysis.tdf': 161 | # here are table names 162 | tables_names(D) 163 | # [1] "CalibrationInfo" "DiaFrameMsMsInfo" 164 | # [3] "DiaFrameMsMsWindowGroups" "DiaFrameMsMsWindows" 165 | # [5] "ErrorLog" "FrameMsMsInfo" 166 | # [7] "FrameProperties" "Frames" 167 | # [9] "GlobalMetadata" "GroupProperties" 168 | # [11] "MzCalibration" "Properties" 169 | # [13] "PropertyDefinitions" "PropertyGroups" 170 | # [15] "Segments" "TimsCalibration" 171 | 172 | # To get only one, use: 173 | table2dt(D, 'Frames') 174 | # Id Time Polarity ScanMode MsMsType TimsId MaxIntensity 175 | # 1: 1 0.3264921 + 9 0 0 192 176 | # 2: 2 0.4347063 + 9 9 8192 2384 177 | # 3: 3 0.5409869 + 9 9 32768 4905 178 | # 4: 4 0.6488865 + 9 9 61440 6206 179 | # 5: 5 0.7566600 + 9 9 94208 6206 180 | # --- 181 | # 11549: 11549 1243.4941418 + 9 9 995598336 129 182 | # 11550: 11550 1243.5991705 + 9 9 995602432 137 183 | # 11551: 11551 1243.7072909 + 9 0 995606528 253 184 | # 11552: 11552 1243.8112220 + 9 9 995631104 167 185 | # 11553: 11553 1243.9193366 + 9 9 995635200 155 186 | # SummedIntensities NumScans NumPeaks MzCalibration T1 T2 187 | # 1: 95955 918 1601 1 25.57090 26.67739 188 | # 2: 579402 918 6598 1 25.57090 26.67739 189 | # 3: 907089 918 8706 1 25.57090 26.67739 190 | # 4: 1192350 918 10820 1 25.57090 26.67739 191 | # 5: 1408123 918 12597 1 25.57090 26.67739 192 | # --- 193 | # 11549: 5065 918 319 1 25.57136 26.63330 194 | # 11550: 5414 918 345 1 25.57128 26.63330 195 | # 11551: 406508 918 6743 1 25.57128 26.63330 196 | # 11552: 8097 918 360 1 25.57128 26.63330 197 | # 11553: 8633 918 397 1 25.57128 26.63330 198 | # TimsCalibration PropertyGroup AccumulationTime RampTime 199 | # 1: 1 1 99.953 99.953 200 | # 2: 1 1 99.953 99.953 201 | # 3: 1 1 99.953 99.953 202 | # 4: 1 1 99.953 99.953 203 | # 5: 1 1 99.953 99.953 204 | # --- 205 | # 11549: 1 1 99.953 99.953 206 | # 11550: 1 1 99.953 99.953 207 | # 11551: 1 1 99.953 99.953 208 | # 11552: 1 1 99.953 99.953 209 | # 11553: 1 1 99.953 99.953 210 | 211 | 212 | # To get all of them as a named list of data.tables: 213 | tdf.tables = tdf.tables(D) 214 | tdf.tables[['TimsCalibration']] 215 | # Id ModelType C0 C1 C2 C3 C4 C5 C6 C7 C8 216 | # 1: 1 2 1 917 213.5998 75.81729 33 1 -0.009065829 135.4364 13.32608 217 | # C9 218 | # 1: 1663.341 219 | 220 | 221 | # Remember, R is ultimately a BAD BAD computer language. 222 | # If you have problems with memory getting freed immediately, 223 | # you can call the garbage collector using: 224 | cleanMem() 225 | ``` 226 | 227 | ### Basic plotting 228 | You can plot the overview of your experiment. 229 | Continuing on the previous example: 230 | 231 | ```R 232 | D.plot_TIC() 233 | ``` 234 | ![](https://github.com/MatteoLacki/timsr/blob/main/fms1_ms2_intensities.png "TIC per frame") 235 | 246 | ### Vaex support? 247 | 248 | Unfortunately, there is yet no equivalent of vaex on R. 249 | But we are monitoring the developments of somewhat similar `dtplyr::lazy_dt` and will possibly encourage its usage once it is tested. 250 | 251 | 252 | ### Plans 253 | * specialized methods for DDA experiments 254 | * going fully open-source with scan2inv_ion_mobility and tof2mz 255 | 256 | 257 | ### Installation 258 | 259 | ```R 260 | install.packages('TimsR') 261 | ``` 262 | or 263 | ```R 264 | # install.packages("devtools") # you will need that. 265 | library(devtools) 266 | 267 | install_github("michalsta/opentims", subdir="opentimsr") 268 | install_github("MatteoLacki/timsr") 269 | ``` 270 | or with git: 271 | ```{bash} 272 | git clone https://github.com/MatteoLacki/timsr 273 | 274 | R CMD build timsr_*.tar.gz 275 | R CMD INSTALL timsr_*.tar.gz 276 | ``` 277 | 278 | # Known issues 279 | 280 | ### R function rt_query 281 | 282 | If you see error: 283 | `Error in col[1] : object of type 'closure' is not subsettable` 284 | then interpret the following set of functions: 285 | ```R 286 | get_left_frame = function(x,y) ifelse(x > y[length(y)], NA, findInterval(x, y, left.open=T) + 1) 287 | get_right_frame = function(x,y) ifelse(x < y[1], NA, findInterval(x, y, left.open=F)) 288 | 289 | rt_query = function(opentims, 290 | min_retention_time, 291 | max_retention_time, 292 | columns=c('frame','scan','tof','intensity','mz','inv_ion_mobility','retention_time') 293 | ){ 294 | RTS = retention_times(opentims) 295 | 296 | min_frame = get_left_frame(min_retention_time, RTS) 297 | max_frame = get_right_frame(max_retention_time, RTS) 298 | 299 | if(is.na(min_frame) | is.na(max_frame)) 300 | stop("The [min_retention_time,max_retention_time] interval does not hold any data.") 301 | 302 | query(opentims, min_frame:max_frame, columns=columns) 303 | } 304 | ``` 305 | This will be patched upon the next possible upload to CRAN. 306 | 307 | ### Too bloat? 308 | 309 | We have a simpler module too. 310 | Check out our [opentimsr package](https://github.com/michalsta/opentims). 311 | 312 | Best wishes, 313 | 314 | Matteo Lacki & Michal (Startrek) Startek 315 | -------------------------------------------------------------------------------- /examples/get_data.R: -------------------------------------------------------------------------------- 1 | library(timsr) 2 | 3 | path = 'path/to/your/data.d' 4 | 5 | # Do you want to have access only to 'frame', 'scan', 'time of flight', and 'intensity'? 6 | accept_Bruker_EULA_and_on_Windows_or_Linux = TRUE 7 | 8 | if(accept_Bruker_EULA_and_on_Windows_or_Linux){ 9 | folder_to_stode_priopriatary_code = "/home/matteo" 10 | path_to_bruker_dll = download_bruker_proprietary_code(folder_to_stode_priopriatary_code) 11 | setup_bruker_so(path_to_bruker_dll) 12 | all_columns = c('frame','scan','tof','intensity','mz','inv_ion_mobility','retention_time') 13 | } else { 14 | all_columns = c('frame','scan','tof','intensity','retention_time') 15 | } 16 | 17 | D = TimsR(path) # get data handle 18 | 19 | print(D) 20 | print(length(D)) # The number of peaks. 21 | # 404183877 22 | 23 | 24 | # Get a data,frame with data from frames 1, 5, and 67. 25 | X = D[c(1,5,67), all_columns] 26 | print(X) 27 | # frame scan tof intensity mz inv_ion_mobility retention_time 28 | # 1: 1 33 312260 9 1174.6558 1.6011418 0.3264921 29 | # 2: 1 34 220720 9 733.4809 1.6000000 0.3264921 30 | # 3: 1 34 261438 9 916.9524 1.6000000 0.3264921 31 | # 4: 1 36 33072 9 152.3557 1.5977164 0.3264921 32 | # 5: 1 36 242110 9 827.3114 1.5977164 0.3264921 33 | # --- 34 | # 224733: 67 917 192745 51 619.2850 0.6007742 7.4056544 35 | # 224734: 67 917 201838 54 655.3439 0.6007742 7.4056544 36 | # 224735: 67 917 205954 19 672.0017 0.6007742 7.4056544 37 | # 224736: 67 917 236501 57 802.1606 0.6007742 7.4056544 38 | # 224737: 67 917 289480 95 1055.2037 0.6007742 7.4056544 39 | 40 | 41 | # Get a dict with each 10th frame, starting from frame 2, finishing on frame 1000. 42 | X = D[seq(2,1000,10), all_columns] 43 | # frame scan tof intensity mz inv_ion_mobility retention_time 44 | # 1: 2 33 97298 9 302.3477 1.6011418 0.4347063 45 | # 2: 2 33 310524 9 1165.3273 1.6011418 0.4347063 46 | # 3: 2 34 127985 9 391.9841 1.6000000 0.4347063 47 | # 4: 2 35 280460 9 1009.6751 1.5988582 0.4347063 48 | # 5: 2 37 329377 72 1268.6262 1.5965746 0.4347063 49 | # --- 50 | # 669553: 992 909 198994 9 643.9562 0.6097471 106.7102786 51 | # 669554: 992 909 282616 9 1020.4663 0.6097471 106.7102786 52 | # 669555: 992 912 143270 9 440.9670 0.6063821 106.7102786 53 | # 669556: 992 915 309328 9 1158.9221 0.6030173 106.7102786 54 | # 669557: 992 916 224410 9 749.2647 0.6018958 106.7102786 55 | 56 | 57 | 58 | # Get all MS1 frames 59 | # print(query(D, frames=MS1(D))) 60 | # ATTENTION: that's quite a lot of data!!! And R will first make a stupid copy, because it's bad. You might exceed your RAM. 61 | 62 | # Getting subset of columns: simply specify 'columns': 63 | D[c(1,5,67), c('scan','intensity')] 64 | # scan intensity 65 | # 1: 33 9 66 | # 2: 34 9 67 | # 3: 34 9 68 | # 4: 36 9 69 | # 5: 36 9 70 | # --- 71 | # 224733: 917 51 72 | # 224734: 917 54 73 | # 224735: 917 19 74 | # 224736: 917 57 75 | # 224737: 917 95 76 | # 77 | # this is also the only way to get data without accepting Bruker terms of service and on MacOS (for time being). 78 | # In that case, you can choose among columns: 79 | # c('frame','scan','tof','intensity','rt') 80 | 81 | # Not specifying columns defaults to extracting only the actaully stored raw data in t'analysis.tdf_raw' without their transformations: 82 | D[100] 83 | # frame scan tof intensity 84 | # 1: 100 35 389679 9 85 | # 2: 100 35 394578 9 86 | # 3: 100 37 78036 9 87 | # 4: 100 37 210934 9 88 | # 5: 100 37 211498 9 89 | # --- 90 | # 7281: 100 910 156846 9 91 | # 7282: 100 910 355234 9 92 | # 7283: 100 911 294204 9 93 | # 7284: 100 913 248788 9 94 | # 7285: 100 915 100120 120 95 | 96 | 97 | D[1:100] 98 | # frame scan tof intensity 99 | # 1: 1 33 312260 9 100 | # 2: 1 34 220720 9 101 | # 3: 1 34 261438 9 102 | # 4: 1 36 33072 9 103 | # 5: 1 36 242110 9 104 | # --- 105 | # 1633354: 100 910 156846 9 106 | # 1633355: 100 910 355234 9 107 | # 1633356: 100 911 294204 9 108 | # 1633357: 100 913 248788 9 109 | # 1633358: 100 915 100120 120 110 | 111 | 112 | # The frame lasts a convenient time unit that well suits chromatography peak elution. 113 | # What if you were interested instead in finding out which frames eluted in a given time 114 | # time of the experiment? 115 | # For this reasone, we have prepared a retention time based query: 116 | # suppose you are interested in all frames corresponding to all that eluted between 10 and 12 117 | # second of the experiment. 118 | pprint(rt_query(opentims, 10, 12)) 119 | # frame scan tof intensity mz inv_ion_mobility retention_time 120 | # 1: 92 33 361758 9 1456.2835 1.6011418 10.08690 121 | # 2: 92 36 65738 9 222.2822 1.5977164 10.08690 122 | # 3: 92 41 308330 9 1153.5909 1.5920078 10.08690 123 | # 4: 92 43 123618 9 378.5190 1.5897245 10.08690 124 | # 5: 92 48 65346 9 221.3651 1.5840168 10.08690 125 | # --- 126 | # 128130: 109 914 138760 65 426.2142 0.6041389 11.91001 127 | # 128131: 109 914 142129 69 437.2109 0.6041389 11.91001 128 | # 128132: 109 914 144566 58 445.2528 0.6041389 11.91001 129 | # 128133: 109 916 138933 91 426.7755 0.6018958 11.91001 130 | # 128134: 109 917 373182 9 1525.5765 0.6007742 11.91001 131 | 132 | 133 | 134 | # All MS1 frames, but one at a time: 135 | for(fr in MS1(D)) print(D[fr, all_columns]) 136 | # Of course, it's better to use lapply or mclapply to speed up things. 137 | 138 | 139 | # Extracting information from 'analysis.tdf': 140 | # here are table names 141 | tables_names(D) 142 | # [1] "CalibrationInfo" "DiaFrameMsMsInfo" 143 | # [3] "DiaFrameMsMsWindowGroups" "DiaFrameMsMsWindows" 144 | # [5] "ErrorLog" "FrameMsMsInfo" 145 | # [7] "FrameProperties" "Frames" 146 | # [9] "GlobalMetadata" "GroupProperties" 147 | # [11] "MzCalibration" "Properties" 148 | # [13] "PropertyDefinitions" "PropertyGroups" 149 | # [15] "Segments" "TimsCalibration" 150 | 151 | # To get only one, use: 152 | table2dt(D, 'Frames') 153 | # Id Time Polarity ScanMode MsMsType TimsId MaxIntensity 154 | # 1: 1 0.3264921 + 9 0 0 192 155 | # 2: 2 0.4347063 + 9 9 8192 2384 156 | # 3: 3 0.5409869 + 9 9 32768 4905 157 | # 4: 4 0.6488865 + 9 9 61440 6206 158 | # 5: 5 0.7566600 + 9 9 94208 6206 159 | # --- 160 | # 11549: 11549 1243.4941418 + 9 9 995598336 129 161 | # 11550: 11550 1243.5991705 + 9 9 995602432 137 162 | # 11551: 11551 1243.7072909 + 9 0 995606528 253 163 | # 11552: 11552 1243.8112220 + 9 9 995631104 167 164 | # 11553: 11553 1243.9193366 + 9 9 995635200 155 165 | # SummedIntensities NumScans NumPeaks MzCalibration T1 T2 166 | # 1: 95955 918 1601 1 25.57090 26.67739 167 | # 2: 579402 918 6598 1 25.57090 26.67739 168 | # 3: 907089 918 8706 1 25.57090 26.67739 169 | # 4: 1192350 918 10820 1 25.57090 26.67739 170 | # 5: 1408123 918 12597 1 25.57090 26.67739 171 | # --- 172 | # 11549: 5065 918 319 1 25.57136 26.63330 173 | # 11550: 5414 918 345 1 25.57128 26.63330 174 | # 11551: 406508 918 6743 1 25.57128 26.63330 175 | # 11552: 8097 918 360 1 25.57128 26.63330 176 | # 11553: 8633 918 397 1 25.57128 26.63330 177 | # TimsCalibration PropertyGroup AccumulationTime RampTime 178 | # 1: 1 1 99.953 99.953 179 | # 2: 1 1 99.953 99.953 180 | # 3: 1 1 99.953 99.953 181 | # 4: 1 1 99.953 99.953 182 | # 5: 1 1 99.953 99.953 183 | # --- 184 | # 11549: 1 1 99.953 99.953 185 | # 11550: 1 1 99.953 99.953 186 | # 11551: 1 1 99.953 99.953 187 | # 11552: 1 1 99.953 99.953 188 | # 11553: 1 1 99.953 99.953 189 | 190 | 191 | # To get all of them as a named list of data.tables: 192 | tdf.tables = tdf.tables(D) 193 | tdf.tables[['TimsCalibration']] 194 | # Id ModelType C0 C1 C2 C3 C4 C5 C6 C7 C8 195 | # 1: 1 2 1 917 213.5998 75.81729 33 1 -0.009065829 135.4364 13.32608 196 | # C9 197 | # 1: 1663.341 198 | 199 | 200 | # Remember, R is ultimately a BAD BAD computer language. 201 | # If you have problems with memory getting freed immediately, 202 | # you can call the garbage collector using: 203 | cleanMem() -------------------------------------------------------------------------------- /man/MS1.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{MS1} 4 | \alias{MS1} 5 | \title{Get MS1 frame numbers.} 6 | \usage{ 7 | MS1(timsr) 8 | } 9 | \arguments{ 10 | \item{timsr}{Instance of TimsR} 11 | } 12 | \value{ 13 | Numbers of frames corresponding to MS1, i.e. precursor ions. 14 | } 15 | \description{ 16 | Get MS1 frame numbers. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | D = TimsR('path/to/your/folder.d') 21 | print(MS1(D)) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /man/TimsR-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \docType{class} 4 | \name{TimsR-class} 5 | \alias{TimsR-class} 6 | \title{Advanced TimsTOF data accessor.} 7 | \description{ 8 | S4 class that facilitates data queries for TimsTOF data. 9 | } 10 | -------------------------------------------------------------------------------- /man/TimsR.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{TimsR} 4 | \alias{TimsR} 5 | \title{Get TimsR data accessor.} 6 | \usage{ 7 | TimsR(path.d) 8 | } 9 | \arguments{ 10 | \item{path.d}{Path to the TimsTOF '*.d' folder containing the data (requires the folder to contain only 'analysis.tdf' and 'analysis.tdf_bin').} 11 | } 12 | \value{ 13 | instance of TimsR class that represents raw data 14 | } 15 | \description{ 16 | Get TimsR data accessor. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | D = TimsR(path_to_.d_folder) 21 | D[1] # First frame. 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /man/cleanMem.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{cleanMem} 4 | \alias{cleanMem} 5 | \title{Clean memory.} 6 | \usage{ 7 | cleanMem(times = 10) 8 | } 9 | \arguments{ 10 | \item{times}{Number of times to run garbage collection.} 11 | } 12 | \value{ 13 | No return value, called for side effects. 14 | } 15 | \description{ 16 | Run garbage collection, by default - 10 times. 17 | } 18 | \details{ 19 | Check \url{https://stackoverflow.com/questions/1467201/forcing-garbage-collection-to-run-in-r-with-the-gc-command} 20 | } 21 | \examples{ 22 | \dontrun{ 23 | cleanMem() 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /man/download_bruker_proprietary_code.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{download_bruker_proprietary_code} 4 | \alias{download_bruker_proprietary_code} 5 | \title{Get Bruker's code needed for running proprietary time of flight to mass over charge and scan to drift time conversion.} 6 | \usage{ 7 | download_bruker_proprietary_code( 8 | target.folder, 9 | net_url = paste0("https://github.com/MatteoLacki/opentims_bruker_bridge/", 10 | "raw/main/opentims_bruker_bridge/"), 11 | mode = "wb", 12 | ... 13 | ) 14 | } 15 | \arguments{ 16 | \item{target.folder}{Folder where to store the 'dll' or 'so' file.} 17 | 18 | \item{net_url}{The url with location of all files.} 19 | 20 | \item{mode}{Which mode to use when downloading a file?} 21 | 22 | \item{...}{Other parameters to 'download.file'.} 23 | } 24 | \value{ 25 | character, path to the output 'timsdata.dll' on Windows and 'libtimsdata.so' on Linux. 26 | } 27 | \description{ 28 | By using this function you aggree to terms of license precised in "https://github.com/MatteoLacki/opentims_bruker_bridge". 29 | The conversion, due to independent code-base restrictions, are possible only on Linux and Windows operating systems. 30 | Works on full open-source solution are on the way. 31 | } 32 | \examples{ 33 | \dontrun{ 34 | download_bruker_proprietary_code("your/prefered/destination/folder") 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /man/intensity_per_frame.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{intensity_per_frame} 4 | \alias{intensity_per_frame} 5 | \title{Get sum of intensity per each frame (retention time).} 6 | \usage{ 7 | intensity_per_frame(timsr, recalibrated = TRUE) 8 | } 9 | \arguments{ 10 | \item{timsr}{Instance of TimsR} 11 | 12 | \item{recalibrated}{Use Bruker recalibrated total intensities or calculate them from scratch with OpenTIMS?} 13 | } 14 | \value{ 15 | integer vector: total intensity per each frame. 16 | } 17 | \description{ 18 | Get sum of intensity per each frame (retention time). 19 | } 20 | \examples{ 21 | \dontrun{ 22 | D = TimsR('path/to/your/folder.d') 23 | print(intensity_per_frame(D)) 24 | print(intensity_per_frame(D, recalibrated=FALSE)) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /man/min_max_measurements.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{min_max_measurements} 4 | \alias{min_max_measurements} 5 | \title{Get border values for measurements.} 6 | \usage{ 7 | min_max_measurements(timsr) 8 | } 9 | \arguments{ 10 | \item{timsr}{Instance of TimsR.} 11 | } 12 | \value{ 13 | data.frame Limits of individual extracted quantities. 14 | } 15 | \description{ 16 | Get the min-max values of the measured variables (except for TOFs, that would require iteration through data rather than parsing metadata). 17 | } 18 | \examples{ 19 | \dontrun{ 20 | D = TimsR('path/to/your/folder.d') 21 | min_max_measurements(D) # this gives a small data-frame with min and max values. 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /man/peaks_per_frame_cnts.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{peaks_per_frame_cnts} 4 | \alias{peaks_per_frame_cnts} 5 | \title{Get the number of peaks per frame.} 6 | \usage{ 7 | peaks_per_frame_cnts(timsr) 8 | } 9 | \arguments{ 10 | \item{timsr}{Instance of TimsR.} 11 | } 12 | \value{ 13 | Number of peaks in each frame. 14 | } 15 | \description{ 16 | Get the number of peaks per frame. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | D = TimsR('path/to/your/folder.d') 21 | print(peaks_per_frame_cnts(D)) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /man/plot_TIC.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{plot_TIC} 4 | \alias{plot_TIC} 5 | \title{Plot intensity per retention time.} 6 | \usage{ 7 | plot_TIC(timsr, recalibrated = TRUE) 8 | } 9 | \arguments{ 10 | \item{timsr}{Instance of TimsR} 11 | 12 | \item{recalibrated}{Use Bruker recalibrated total intensities or calculate them from scratch with OpenTIMS?} 13 | } 14 | \value{ 15 | No return value, called for side effects. 16 | } 17 | \description{ 18 | Plot will split 'MS1' and 'MS2'. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | D = TimsR('path/to/your/folder.d') 23 | plot_TIC(D) 24 | plot_TIC(D, recalibrated=FALSE) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /man/query.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{query} 4 | \alias{query} 5 | \title{Query for raw data.} 6 | \usage{ 7 | query(timsr, frames, columns = all_columns) 8 | } 9 | \arguments{ 10 | \item{timsr}{Instance of TimsR.} 11 | 12 | \item{frames}{Vector of frame numbers to extract.} 13 | 14 | \item{columns}{Vector of columns to extract. Defaults to all columns.} 15 | } 16 | \value{ 17 | data.frame with selected columns. 18 | } 19 | \description{ 20 | Get the raw data from Bruker's 'tdf_bin' format. 21 | Defaults to both raw data ('frame','scan','tof','intensity') and its tranformations into physical units ('mz','inv_ion_mobility','retention_time'). 22 | } 23 | \examples{ 24 | \dontrun{ 25 | D = TimsR('path/to/your/folder.d') 26 | print(query(D, c(1,20, 53)) # extract all columns 27 | print(query(D, c(1,20, 53), columns=c('scan','intensity')) # only 'scan' and 'intensity' 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /man/retention_times.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{retention_times} 4 | \alias{retention_times} 5 | \title{Get the retention time for each frame.} 6 | \usage{ 7 | retention_times(timsr) 8 | } 9 | \arguments{ 10 | \item{timsr}{Instance of TimsR.} 11 | } 12 | \value{ 13 | Retention times corresponding to each frame. 14 | } 15 | \description{ 16 | Get the retention time for each frame. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | D = TimsR('path/to/your/folder.d') 21 | print(retention_times(D)) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /man/rt_query.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{rt_query} 4 | \alias{rt_query} 5 | \title{Get the retention time for each frame.} 6 | \usage{ 7 | rt_query(timsr, min_retention_time, max_retention_time, columns = all_columns) 8 | } 9 | \arguments{ 10 | \item{timsr}{Instance of TimsR} 11 | 12 | \item{min_retention_time}{Lower boundry on retention time.} 13 | 14 | \item{max_retention_time}{Upper boundry on retention time.} 15 | 16 | \item{columns}{Vector of columns to extract. Defaults to all columns.} 17 | } 18 | \value{ 19 | data.frame with selected columns. 20 | } 21 | \description{ 22 | Get the retention time for each frame. 23 | } 24 | \examples{ 25 | \dontrun{ 26 | D = TimsR('path/to/your/folder.d') 27 | print(query_slice(D, 10, 200, 4)) # extract every fourth frame between 10 and 200. 28 | print(query_slice(D, 10, 200, 4, columns=c('scan','intensity')) # only 'scan' and 'intensity' 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /man/setup_bruker_so.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{setup_bruker_so} 4 | \alias{setup_bruker_so} 5 | \title{Dynamically link Bruker's DLL to enable tof-mz and scan-inv_ion_mobility conversion.} 6 | \usage{ 7 | setup_bruker_so(path) 8 | } 9 | \arguments{ 10 | \item{path}{Path to the 'libtimsdata.so' on Linux or 'timsdata.dll' on Windows, as produced by 'download_bruker_proprietary_code'.} 11 | } 12 | \value{ 13 | No return value, called for side effects. 14 | } 15 | \description{ 16 | By using this function you aggree to terms of license precised in "https://github.com/MatteoLacki/opentims_bruker_bridge". 17 | The conversion, due to independent code-base restrictions, are possible only on Linux and Windows operating systems. 18 | Works on full open-source solution are on the way. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | so_path = download_bruker_proprietary_code("your/prefered/destination/folder") 23 | setup_bruker_so(so_path) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /man/sub-TimsR-ANY-ANY-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{[,TimsR,ANY,ANY-method} 4 | \alias{[,TimsR,ANY,ANY-method} 5 | \title{Get some frames of data.} 6 | \usage{ 7 | \S4method{[}{TimsR,ANY,ANY}(x, i) 8 | } 9 | \arguments{ 10 | \item{x}{OpenTIMS data instance.} 11 | 12 | \item{i}{An array of nonzero indices to extract.} 13 | } 14 | \value{ 15 | data.table 16 | } 17 | \description{ 18 | Get some frames of data. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | D = TimsR('path/to/your/folder.d') 23 | print(head(D[10])) 24 | print(head(D[10:100])) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /man/sub-TimsR-ANY-character-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{[,TimsR,ANY,character-method} 4 | \alias{[,TimsR,ANY,character-method} 5 | \title{Get some frames of data.} 6 | \usage{ 7 | \S4method{[}{TimsR,ANY,character}(x, i, j) 8 | } 9 | \arguments{ 10 | \item{x}{OpenTIMS data instance.} 11 | 12 | \item{i}{An array of nonzero frame numbers to extract.} 13 | 14 | \item{j}{A vector of strings with column names to extract.} 15 | } 16 | \value{ 17 | data.table 18 | } 19 | \description{ 20 | Get some frames of data. 21 | } 22 | \examples{ 23 | \dontrun{ 24 | D = TimsR('path/to/your/folder.d') 25 | all_cols = c('frame','scan','tof','intensity', 26 | 'mz','inv_ion_mobility','retention_time') 27 | print(D[c(1,20, 53), all_cols] 28 | # extracted all columns 29 | 30 | print(D[c(1,20, 53), c('scan','intensity')] 31 | # only 'scan' and 'intensity' 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /man/table2dt.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{table2dt} 4 | \alias{table2dt} 5 | \title{Extract tables from sqlite database analysis.tdf.} 6 | \usage{ 7 | table2dt(timsr, names) 8 | } 9 | \arguments{ 10 | \item{timsr}{Instance of TimsR} 11 | 12 | \item{names}{Names to extract from the sqlite database.} 13 | } 14 | \value{ 15 | data.table 16 | } 17 | \description{ 18 | Export a table from sqlite. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | D = TimsR('path/to/your/folder.d') 23 | print(head(table2dt(D, "Frames"))) # Extract table "Frames". 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /man/tables_names.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{tables_names} 4 | \alias{tables_names} 5 | \title{Extract tables from sqlite database analysis.tdf.} 6 | \usage{ 7 | tables_names(timsr) 8 | } 9 | \arguments{ 10 | \item{timsr}{Instance of TimsR} 11 | } 12 | \value{ 13 | character, names of tables. 14 | } 15 | \description{ 16 | Extract tables from sqlite database analysis.tdf. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | D = TimsR('path/to/your/folder.d') 21 | print(tables_names(D)) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /man/tdf.tables.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/timsr.R 3 | \name{tdf.tables} 4 | \alias{tdf.tables} 5 | \title{Explore the contentents of the sqlite .tdf database.} 6 | \usage{ 7 | tdf.tables(timsr) 8 | } 9 | \arguments{ 10 | \item{timsr}{Instance of TimsR} 11 | } 12 | \value{ 13 | List of data.tables filled with data from 'analysis.tdf'. 14 | } 15 | \description{ 16 | Explore the contentents of the sqlite .tdf database. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | D = TimsR('path/to/your/folder.d') 21 | print(tdf.tables(D)) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ms1_ms2_intensities.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MatteoLacki/timsr/bcaf269e03ee22bb74a8fb4a858171e271490ab2/ms1_ms2_intensities.png --------------------------------------------------------------------------------