Skip to contents

Set row names and remove all non-numeric columns. This is useful for reformatting data objects in MotrpacRatTraining6moData, e.g., MotrpacRatTraining6moData::PROT_HEART_NORM_DATA

Usage

df_to_numeric(df, rownames = "feature_ID")

Arguments

df

data frame with at least one numeric column

rownames

either NULL, a character specifying a column name in df, or a vector. Specifies target row names. Default: "feature_ID"

Value

numeric data frame

Examples

df = MotrpacRatTraining6moData::PROT_HEART_NORM_DATA
df[1:5,1:8]
#>   feature     feature_ID tissue assay 90237015805 90245015805 90441015805
#> 1    <NA> XP_017456475.1  HEART  PROT     0.00769    -0.05952     0.10992
#> 2    <NA> XP_017447817.1  HEART  PROT     0.09326    -0.08879     0.31763
#> 3    <NA>    NP_446341.1  HEART  PROT    -0.11469     0.10623     0.08138
#> 4    <NA>    NP_071796.2  HEART  PROT     0.05903    -0.06490     0.05673
#> 5    <NA> NP_001157776.1  HEART  PROT     1.24616     0.63626     0.15487
#>   90420015805
#> 1    -0.00229
#> 2     0.07739
#> 3     0.08464
#> 4    -0.07494
#> 5    -0.39231
df_to_numeric(df)[1:5,1:4]
#>                90237015805 90245015805 90441015805 90420015805
#> XP_017456475.1     0.00769    -0.05952     0.10992    -0.00229
#> XP_017447817.1     0.09326    -0.08879     0.31763     0.07739
#> NP_446341.1       -0.11469     0.10623     0.08138     0.08464
#> NP_071796.2        0.05903    -0.06490     0.05673    -0.07494
#> NP_001157776.1     1.24616     0.63626     0.15487    -0.39231

df = load_sample_data("SKM-GN", "TRNSCRPT")
#> TRNSCRPT_SKMGN_NORM_DATA
df[1:5,1:8]
#>   feature         feature_ID tissue    assay 90560015512 90581015512
#> 1    <NA> ENSRNOG00000000008 SKM-GN TRNSCRPT     0.04044    -0.09760
#> 2    <NA> ENSRNOG00000000012 SKM-GN TRNSCRPT     2.61487     2.78841
#> 3    <NA> ENSRNOG00000000021 SKM-GN TRNSCRPT     2.17049     1.70091
#> 4    <NA> ENSRNOG00000000024 SKM-GN TRNSCRPT     1.79255     1.26161
#> 5    <NA> ENSRNOG00000000033 SKM-GN TRNSCRPT     5.39651     5.50703
#>   90406015512 90449015512
#> 1    -0.70731     0.13853
#> 2     2.95085     2.46788
#> 3     1.69314     1.90443
#> 4     1.67725     1.66870
#> 5     5.50525     5.57206
df_to_numeric(df)[1:5,1:4]
#>                    90560015512 90581015512 90406015512 90449015512
#> ENSRNOG00000000008     0.04044    -0.09760    -0.70731     0.13853
#> ENSRNOG00000000012     2.61487     2.78841     2.95085     2.46788
#> ENSRNOG00000000021     2.17049     1.70091     1.69314     1.90443
#> ENSRNOG00000000024     1.79255     1.26161     1.67725     1.66870
#> ENSRNOG00000000033     5.39651     5.50703     5.50525     5.57206

df = MotrpacRatTraining6moData::METAB_NORM_DATA_FLAT 
df[1:5,1:8]
#>                                   feature                 feature_ID tissue
#> 1                                    <NA>          1-Methylhistidine SKM-GN
#> 2          METAB;SKM-GN;3-Methylhistidine          3-Methylhistidine SKM-GN
#> 3                                    <NA>                    Alanine SKM-GN
#> 4 METAB;SKM-GN;alpha-Amino-N-butyric-acid alpha-Amino-N-butyric-acid SKM-GN
#> 5     METAB;SKM-GN;alpha-Aminoadipic-acid     alpha-Aminoadipic-acid SKM-GN
#>   assay        dataset  10023259  10024735  10025626
#> 1 METAB metab-t-amines -2.021833 -2.079719 -3.436179
#> 2 METAB metab-t-amines -5.701379 -5.434643 -3.936401
#> 3 METAB metab-t-amines  3.187501  3.215838  2.607263
#> 4 METAB metab-t-amines -4.377759 -4.316324 -5.241371
#> 5 METAB metab-t-amines -7.332883 -7.265484 -7.700365
rn = paste(df$assay, df$tissue, df$feature_ID, df$dataset, sep=";")
df_to_numeric(df, rownames = rn)[1:5,1:3]
#>                                                         10023259  10024735
#> METAB;SKM-GN;1-Methylhistidine;metab-t-amines          -2.021833 -2.079719
#> METAB;SKM-GN;3-Methylhistidine;metab-t-amines          -5.701379 -5.434643
#> METAB;SKM-GN;Alanine;metab-t-amines                     3.187501  3.215838
#> METAB;SKM-GN;alpha-Amino-N-butyric-acid;metab-t-amines -4.377759 -4.316324
#> METAB;SKM-GN;alpha-Aminoadipic-acid;metab-t-amines     -7.332883 -7.265484
#>                                                         10025626
#> METAB;SKM-GN;1-Methylhistidine;metab-t-amines          -3.436179
#> METAB;SKM-GN;3-Methylhistidine;metab-t-amines          -3.936401
#> METAB;SKM-GN;Alanine;metab-t-amines                     2.607263
#> METAB;SKM-GN;alpha-Amino-N-butyric-acid;metab-t-amines -5.241371
#> METAB;SKM-GN;alpha-Aminoadipic-acid;metab-t-amines     -7.700365