2013-10-25 48 views
2

當我嘗試這樣做的時間超過1天。嘗試了我所知道的所有方式,但有時候你卡住了,無法做任何事情。我很絕望。我甚至寫了一個很長的帖子來展示一切應該展示的東西。如果您有任何建議,請對其發表評論。這是最後一次。我承諾。循環與anova測試。列中的p值。

這是我的數據:

> tbl_reo 

    id   Sequence   variable   value 
    75 AAAAGAAAVANQGKK BiotinControl1_2 3893050.50 
    192 AAAAGAAAVANQGKK BiotinControl1_2 900604.61 
    3770 AAFTKLDQVWGSE  BiotinControl1_2 90008.14 
    934 AAIKFIKFINPKINDGE BiotinControl1_2 656399.2021 
    1012 AAIKFIKFINPKINDGE BiotinControl1_2 359937.85 
    1970 AAIKFIKFINPKINDGE BiotinControl1_2 447089.3547 
    75 AAAAGAAAVANQGKK BiotinControl2  2717893.323 
    192 AAAAGAAAVANQGKK BiotinControl2  741299.3331 
    3770 AAFTKLDQVWGSE  BiotinControl2  87127.07152 
    934 AAIKFIKFINPKINDGE BiotinControl2  646758.138 
    75 AAAAGAAAVANQGKK BiotinTreatment1_2 3435216.403 
    192 AAAAGAAAVANQGKK BiotinTreatment1_2 818936.8906 
    3770 AAFTKLDQVWGSE  BiotinTreatment1_2 85120.95436 
    934 AAIKFIKFINPKINDGE BiotinTreatment1_2 1068384.547 

,我想使用來計算p值的代碼:

我的代碼:

tbl_anv <- tbl_all_onlyK[,c("id", "BiotinControl1_2", "BiotinControl2", "BiotinControl3", "BiotinTreatment1_2", "BiotinTreatment2", "BiotinTreatment3", "Sequence")] 

tbl_reo <- melt(tbl_anv, measure.vars=2:7) 

set.seed(1) 
vars <- c("id", "BiotinControl1_2", "BiotinControl2", "BiotinControl3", 
     "BiotinTreatment1_2", "BiotinTreatment2", "BiotinTreatment3", 
     "Sequence") 

tbl_reo <- as.data.frame(tbl_reo) 

by(tbl_reo,tbl_reo$Sequence,function(x){ 
    anova(lm(value ~ variable, data = x))$"Pr(>F)"[1] 
    }) 

錯誤ocurs:

There were 50 or more warnings (use warnings() to see the first 50) 

無論如何,如何c我這樣做,並在單獨的列中導出p值。

這就是我想對我自己做的事:

aov_test <- by(tbl_reo,tbl_reo$Sequence,function(x){ 
anova(lm(value ~ variable, data = x))$"Pr(>F)"[1] 
}) 
tbl_reo[,5] <- aov.test[[1]]$'Pr(>F)'[1] 

編輯: 所以我跟着你的建議,並試圖盡我所能告訴你我的問題。因此,讓我們從頭部()開始:

> dput(head(tbl_reo)) 
structure(list(id = c(75L, 192L, 3770L, 934L, 1012L, 1970L), 
Sequence = structure(c(1L, 1L, 3L, 5L, 5L, 5L), .Label = c("AAAAGAAAVANQGKK", 
"AAANILFSDHAD", "AAFTKLDQVWGSE", "AAIELRE", "AAIKFIKFINPKINDGE", 
"AAIYKLLKSHFRNE", "AAKKFEE", "AAKYFRE", "AANVKKTLVE", "AARAGELLKE", 
"AARDSKSPIILQTSNGGAAYFAGKGISNE", "AAVKARVASIDE", "AAVKASAPGSVILLE", 
"AEKLKAE", "AEQVKKE", "AFAKRQGKE", "AFGSGTAAVVSPIKE", "AGIPAGVVNILPGSGRVVGE", 
"AGISKDGQTRE", "AGSHGKDAWGVFRVHAFE", "AHSFSSSLASAE", "AIDALNGMLLNGQE", 
"AITYSWTLLTE", "AKAKKAAKKAANAKQQQE", "AKALVAQGVKFIAE", "AKAQGVAVQLKRQPAQPRE", 
"AKIGKKVE", "AKKVVKKAFEE", "AKNKKYALDIIKE", "ALANAGVTDIVLAVNYRPE", 
"ALDFFARGLVKSPIKVVGLSTLPE", "ALFHPSVLGLE", "ALKIWKRFRE", 
"ALKPDSQKSYAE", "ALLLKVNQIGTLSE", "ALRIGSE", "ALRLVE", "AMRIGSE", 
"ANIIKLVE", "ANNKWNKLFSE", "ANVTGLRDAMFKGE", "AQKVRDQITSLKE", 
"AQRVQAKNQLE", "ARINFGIEKAKE", "ASAGIQLSPKFVKLVSWYDNE", "ASFVLPTWAAKE", 
"ASKLAAYNKKSTISARE", "ATSSIVMFSLNE", "ATTNAPWYKGWEKE", "ATVGAGLPIISFLRE", 
"AVDATHLAE", "AVIRLSKE", "AVSKVYARSVYDSRGNPTVE", "AVVTVPAYFNDSQRQATKD", 
"AVWYGPPKAANLGGVAVSGLE", "AWFPYQKE", "AYSPFGSANAPLLKE", "DGWVPGKNLFTVE", 
"DHSFINYKQNVE", "DILYKIYKGVSE", "DLYQTFARTVE", "DNVKAHPRIE", 
"DQVRNYVMQYIQE", "DSVYLAKLAE", "DVHNLFTYAKE", "DVKISAGTLLKGTE", 
"DVQKFRHE", "EAVAKAAE", "EKPLFLVFHGGSGSTVQE", "EQRPGTPLFTVKAYLPVNE", 
"ERIAALE", "FAKSLPRLDGLSVQE", "FALKHFPDYE", "FAPYGTITSAKVMRTE", 
"FASLFPLKQAPAFLGPKGLKLTE", "FEQKNAGGVGE", "FFIDRPE", "FFIRDTKNLE", 
"FGINTTVQE", "FGNRPMILHQIE", "FGVTKARWPAKSVKFVQGLLQNAAANAE", 
"FIFSKYQILE", "FKMAKPE", "FKSMIKNNE", "FKTKYNSDPYQLE", "FLAADKE", 
"FLKKILVDNKLE", "FLLSYGKE", "FMIAPTGAKTFAE", "FMISQLGLQKKNIKIHGF", 
"FNRGLALE", "FNSQPDYRE", "FQKDAKRFE", "FQKTGPFE", "FRNGMINVSPIGRNASTEE", 
"FRTASAQLE", "FSGSLLRSKFNTSNE", "FSRWFNHIASKADE", "FSTNVKDE", 
"FTADGKVKPE", "FTPETPSPLIGILE", "FVADGLLQGFGNE", "FVAYPIQLLVTKE", 
"FVAYPIQLVVTKE", "FVDIINSRN", "FVSSKHGSVSAE", "FYKSLKLPYRIVGIVSGE", 
"GAAPGGFPGGAPPAPE", "GAIWNINSFDQWGVE", "GARYGPSLMPGGSEE", 
"GEKTMGAKITKSLE", "GGLGPINIPLLADTNHSLSRD", "GGTLIGTARSME", 
"GGVAPNIQTAEE", "GGVIIITHSAE", "GIFSGTLSYIFNE", "GIKVPIHIVQE", 
"GILQRWTKGFDIPNIE", "GILQRWTKGFDIPNVE", "GILVASPFVELE", "GIPAGWQGLDNGPE", 
"GIPPDQQRLIFAGKQLE", "GISKKTRIAGVVYHPSNNE", "GKKIATYQE", 
"GKLKGVLGYTE", "GLDKIFQE", "GLGWGNNASAAIQRVGLGE", "GLNHLPVQKQIVE", 
"GMMANGIAAGGQLTTTTE", "GMRWAGNANE", "GNDIHALAAKLLQE", "GQALKKKKGKSAE", 
"GRGINSSYAVWNDVTGKAHE", "GRHSGYGKRKGTRE", "GSDVLNTWKKE", 
"GSRKVDGQKVKASKE", "GTAVSQADVTVFKAFQSAYPE", "GTERSAYYTWAAE", 
"GTRAVTKYSSSTQA", "GVVLGVEKRATSPLLE", "GWGTPHIKPYGNLSLDPSACVFHYAFE", 
"GYSGVEVRVTPTKTE", "GYVGRTQPKKGGEGE", "GYWNGKITVDE", "HDHAGVPLKISPPVVAYRE", 
"HIIQAKADAQRE", "HIVPGTYIQE", "HKFAIPAINVTSSSTAVAALE", "HKVVNGNSADAAYAQVE", 
"HLQPHFTTNDGLE", "HNLRVISE", "HQIRAKFVE", "HQKYTREQVGCKE", 
"IAKLNIPTGIPLVFE", "IAQHIFTKLNSNGYLEE", "IDASKPVKLTLLISE", 
"IDPINALQAAME", "IDVAWLKANAKE", "IEAISSPLMGIFE", "IFDANVQRLKE", 
"IFFKIKKTTPLRRLME", "IFGGYLYFAQAPSAAE", "IFGGYLYFAQAPSAAEFHTE", 
"IFGPVVTVAKFKTLEE", "IFGPVVTVTKFKSADE", "IFLHSLPVKE", "IFSTYADNQPGVLIQVFE", 
"IGATTSVFPFNKSMIEYLE", "IGNSGMFRPEMLE", "IGSLTRQGAKGGLLE", 
"IHPLLPQDE", "IIAGNVATRE", "IIGGTTRIPTLKQSISE", "IIKKNFDLRPGVLVKE", 
"IISNAKGQVVGSIIALDRQE", "IKGFFSFATQKLDE", "IKHLPFNVVNKDGKPAVE", 
"IKKVVKAAAE", "IKLFNKWSFEE", "IKLVKLIQE", "ILIVTKDGVRKE", 
"ILKIVPGRVSTE", "ILKKLDE", "ILLARNLI", "ILNKLALRILKNE", "ILNSQAPEE", 
"ILSKLASAGATE", "ILWRQKE", "IMLPVFDAPQNLVE", "IMLQLGIPREE", 
"IMLWNLAAKKAMYTLSAQDE", "INLPFITADASGPKHINMKFSRAQFE", "INLWFKKEE", 
"IQLNGGSISE", "IQPRANIQLDFPE", "IRVFQGE", "ISAMVLTKMKE", 
"ISDTMWPGQAMTLKVE", "ISDVFAKWNNGVLD", "ISLAAFGRKE", "ISTMIRWGLKPYLFVLNNDGYTIE", 
"ITDIKQFLE", "ITHPTIVDGWFRE", "ITLGKYLFE", "ITQLMSLIINTVYSNKE", 
"ITVDAPKAHE", "ITYLNNRAAAEYE", "IVERLNTASIPE", "IVFASPPRKSDGKVSPE", 
"IVFNMSREE", "IVNLTLPDGTVRQGQVLE", "IVPKLME", "IVRVNKNAPAVE", 
"IVSRFKTE", "IYEKME", "IYFSLNNGVRIPALGLGTANPHEKLAE", "IYNHIQLRE", 
"IYNHIQLREE", "IYPYGSRGPKGLKE", "KAAKVTKAAQKAAKK", "KAALQTYLPKIKE", 
"KAEQVFQNVKNILAE", "KAITYSHAAKE", "KAKIGQKE", "KAKKANNPQHSITKDE", 
"KALTYTPPKKQKAEKPKAE", "KAQRAPLEE", "KAVAYWKTLKTDE", "KDFATFAKE", 
"KDYASVVPPRHNE", "KEKLTQQKKE", "KFAAGTKALLDE", "KFINSEIE", 
"KFNAVPIFLSDE", "KFSERLLNE", "KGAQTYVKKVIGSFKDWE", "KGCDIIVKNHE", 
"KGLLSATQFTQPALTLME", "KGLSKKGGNIPMIPGWVMDFPTGKE", "KGQIVGRYVVDTSK", 
"KGTGKSNKITITNDKGRLSKE", "KGVFRSIVPSGASTGVHE", "KGVFRSIVPSGASTGVHEALE", 
"KGVITTQAE", "KGWVPVTKLGRLVKAGKITTIEE", "KIFTVPTETLQAVTKHFISE", 
"KIGDLNFLIGPKLYE", "KKAADALLLKVNQIGTLSE", "KKAGKTLDVVE", 
"KKAPAAAPAASKKKEE", "KKIDLASIRE", "KKPKTKKVKEE", "KKQAIRSKQE", 
"KKTISLKTPLKTLVILHSDE", "KKVYPDVLYTSKLSRAIQTANIALE", "KKYIATIGVE", 
"KLAAQRKAE", "KLIHGPKAQYNE", "KLIHNDSSYNHE", "KLKAAYSYMFDSLRE", 
"KLKAERE", "KLKKVLSANTNAPFSVE", "KLSGIANNRDE", "KLVAVLK", 
"KLYVGRAQKKNE", "KMIKPKEGRIE", "KMSSGYYLGE", "KMSTRAAPFEQRLPE", 
"KNLFTGWVDVKLSAKGQQE", "KNLKPLAIIKGWGE", "KNMDAATALVGSGPAFVLLMLE", 
"KNVPLYQHLAD", "KQLYSFDLE", "KQNLLAVE", "KRVSGMFLGE", "KSPFLDALKAKNFE", 
"KTFVNVAKPFHKE", "KTKLQGMLNKAEE", "KTMGAKITKSLE", "KTQAFKKHVDE", 
"KTVRKHLERQGWIE", "KVFNAYPAARE", "KVGLRLSPYGVFNSMSGGAE", 
"KVILKMKE", "KVIRFQEE", "KVSVLKALGAE", "KYFPGLLRATNE", "KYSLAPVAKE", 
"LAKKQKKLE", "LDALIAQGRE", "LDASNKAAKE", "LDLARPIYLPTASYGHFTNQE", 
"LDTAQKHID", "LDTIRNME", "LEARIPE", "LFAKFGPIVSASLE", "LFAKHGE", 
"LFDTHRVIVNE", "LFLKQLVVGGLDRVYE", "LFRSIGGE", "LGAVALKGALAKVPE", 
"LGAVNLHE", "LGDKAVYAGE", "LGDNAVFAGE", "LGGEKKQKGQALQF", 
"LGGKSPNIVFADAE", "LGGTVVSLSDSKGCIISE", "LGILPRDILTKE", "LGIYSHE", 
"LGKGSFKYAWVLD", "LGKVLAKVIGKE", "LGMLAGADRVE", "LGTPFGVTIDFE", 
"LHGNAKKAAEE", "LICSYRSKIETE", "LIGGSADLTPSNLTRWKE", "LIHQNEVPLVLLSSGVGVTPLLAMLE", 
"LIHSKVGGE", "LIKLTGKLIE", "LILNGGFSPLTGFLNE", "LINNLGTIAKSGTKAFME", 
"LKADLRPLQIKSIRE", "LKAHNINVVDK", "LKAQSKPHVGDE", "LKHLVGPEKAAE", 
"LKIQRPLHE", "LKKKGILFVGSGVSGGEE", "LKKQKTAE", "LKKQQKEAE", 
"LKKSANVGKKKE", "LKPTVILKLLKE", "LKRAIDLNKE", "LKRIMINCFNE", 
"LKRIPE", "LKTNGKFQVDKSIIE", "LKYFGKALE", "LLAAFKAYLE", "LLAVPVVKGRKTEKE", 
"LLAYQFASPVRWIE", "LLESPNNKVVPATNQIE", "LLKTNRISNE", "LLKTNRISNEQYE", 
"LLLLDVAPLSLGIE", "LLLQQRATE", "LLRLVLLE", "LMAKLANDSPLAIE", 
"LNAATGSKTSLYDKKE", "LNAAYAADGYARIKGMSCIITTFGVGE", "LNKGLTKKGGNIPMIPGWVMEFPTGKE", 
"LNNAAAKKYDLE", "LNQLLKLVSE", "LPAWSKLQKIYE", "LPGVAFLSEKK", 
"LPKNSTSSKDKKKKN", "LQAQLDYLNAE", "LQDIANPIMSKLYQAGGAPGGAAGGAPGGFPGGAPPAPE", 
"LQGKLTGMAFRVPTVD", "LQGKLTGMAFRVPTVDVSVVD", "LRPLQFKSIRE", 
"LRQATGGQAFPQMVFD", "LSALNGIAGSYAE", "LSFALIHKE", "LSFPFEWAFAGTNE", 
"LSGIPPAPRGVPQIE", "LSKISGVDSSLIFPALE", "LSKSKTSPYVLPVPFLNVLNGGSHAGGALALQE", 
"LSLLFNVIPDRYTKYD", "LSNVINMFFE", "LSQGTWLNKPKSVFQE", "LSRIGEFE", 
"LTQFPAFVTPMGKGSIDE", "LTQLKKE", "LTSLTDYVTRMPE", "LTVKLNKE", 
"LVARVQGGEE", "LVFGQTFTDHMLTIPWSAKE", "LVGRINGQFGTVE", "LVILGDSNVVRE", 
"LVKVGHDNLVGE", "LVRDNKLIGNFTLAGIPPAPKGVPQIE", "LVRFSYGQDLE", 
"LVSLPNIILTPHIGGSTEE", "LVTAPLDGTILE", "LYGNIVMSGGTTMFPGIAE", 
"LYGTAIGARSQGAKTYLE", "LYPGRPLAIALD", "LYPGRPLAIALDTKGPE", 
"LYSTSSSSTSSSATKN", "MATLYDGLE", "MAVAIKKE", "MAVKFGKNAF", 
"MFFVSKVMNNE", "MFNDFLNAGAE", "MGQKKAPDGRIVE", "MIGSVVGIYNGKAFNQVE", 
"MIGSVVGIYNGKAFNQVEIRPE", "MIISSPSDGQVKE", "MIVLHLPSPVTAQAYRAE", 
"MKPTSIEKE", "MLAQDKLVAE", "MLGHYLGE", "MLGNWSFGDYFKKE", 
"MLNRISPKILDE", "MLRAAGKE", "MNNIIAASRRH", "MPPQIPNE", "MQTAAQSSSIE", 
"MQTEIKE", "NAHLKKNFKPQGSIE", "NALKLAKWLE", "NAVDRLLVE", 
"NFAPFLKTILPE", "NFIQSIME", "NGFINNPIVISPTTTVGE", "NGHSPSEAFNE", 
"NGITFPKDAPSPFIFKTLE", "NGIVTYAAKE", "NGLLSFVQYVIAPIQE", 
"NGLTAYRLGKE", "NGSFLLYIDRHLVHE", "NGTVTAANASPINDGAAAVILVSE", 
"NGVAKGSFKD", "NISNNYMIGAINAE", "NKERILTE", "NKIIRMPLVE", 
"NKIVRKPLME", "NKKVIITGAPAAFSPTCTVSHIPGYINYLDE", "NKVQYIAGARPWTHVQKVDIALPCATQNE", 
"NKVSPADAAKKAL", "NLHILE", "NLKDTSSGGVTHANE", "NLKKGSTVTSNGLNWE", 
"NLKPSKPSYYLDPE", "NLLPLQSGIGNIANAVIE", "NLTVNPNVNE", "NMKLKLIEPLRE", 
"NNIFNMVVE", "NNIFNMVVEIPRWTNAKLE", "NNMLHGNTMTVTGDTLAE", 
"NNYKKRLLGTAFKSSPFGGSSHAKGIVLE", "NQGLKTATYPYWANE", "NQQGVNNFDE", 
"NRGIKVANPVWSTIPFISE", "NRKISAVSTYFE", "NRNVGKTLVNKSTGLKNASDALKGRVVE", 
"NRNVGKTLVNKSTGLKSASDALKGRVVE", "NRVKSDMLKE", "NSLLSSGTSQDSLRE", 
"NTQLMNRDNIE", "NTSLSPKFVYQGE", "NVKTDSRNMPVKE", "NVQLYNGFVFHTGSLEE", 
"NVQNGEVRFE", "NVRDKGNSALLE", "NVSSNIVKNAE", "NYNLLDTSGVAKVIE", 
"NYTVERVNE", "PKLVLVRHGQSE", "PKLVLVRHGQSEWNE", "QAKLTAATNAKQ", 
"QAVGGIYSVLNKKRGQVVSE", "QDKKKKSNH", "QDPSKSKVVVFE", "QDVPLIVPVVNPE", 
"QGAQVLFASTDSE", "QGKPYISLPKGKGIKLSIAEE", "QGLKIDGPGFE", 
"QHPRYGGVYVGTLSKPE", "QHPRYGGVYVGTLSKPEVKE", "QISSMVLGKMKE", 
"QIVYALKLPGIIHIDAAE", "QLADYLIGVQY", "QLASQLVDLKKE", "QLGIHYE", 
"QLYKNDSNNNNNNNGNNAE", "QQGKNATVSVEE", "QRPGTPLFTVKAYLPVNE", 
"QRTKVEHVRE", "QSPRPGQQAFE", "QSPYVSWVSYPGLASHSHHE", "QSTKFGTEIITE", 
"QTYKKPTGGIVTVRSE", "QVADISSAKVNFKSLE", "QVAKWVNLAQKE", "RAVPHGKWQDE", 
"RDLIKKKTKNNE", "RFLNVFPKLVEE", "RGEIKKGE", "RGLPVKLTYTDNKTSKE", 
"RHIQVGDGLE", "RLAIVGVE", "RLLWYLARE", "RLNTASIPE", "RLNTASIPENVE", 
"RLTSLNVVAGSDLRRTSIIGTIGPKTNNPE", "RLVAIAEQD", "RMHVLKKQYE", 
"RNAAYQKE", "RNAAYQKEYE", "RNKIHQYLFQE", "RQLNAVLE", "RQLNAVLEE", 
"RTSLFLNLANDPTIE", "RTVLFPIKYHE", "RVKANAAKRAE", "RYKLVPGIFADVKNLKE", 
"RYKYVDPNVLPE", "RYVFLLDPMLATGGSAIMATE", "SALSYAALILADSE", 
"SCKMPQTVE", "SDKSKWLTGVE", "SEYWPRLTKE", "SFAANWGVMVSHRSGETE", 
"SFQAVYNKLTGKQIVFE", "SGSKLKFYVLHGDGVE", "SGTLGTKGNTQVIIPRLTE", 
"SGTVFDSSYSRGSPIAFE", "SHIGVAKKLE", "SHLIPSATTGE", "SIAVLSAMKME", 
"SIAYSLKNTISE", "SIQKTKE", "SIRVGEYNAE", "SISDSLSSKPHNFE", 
"SKFAKAYAQGVSKKE", "SKFKGDITWLPVRRKAYWE", "SKLPTYTAKDSAVATRKLSE", 
"SLDQAWSLLRIYPKE", "SLGSPSGATKARIVVAKSGEL", "SLIDAKTGLPKE", 
"SLKTGNAGPRPACGVIGLTN", "SLQNKGQEVKE", "SLRGLGGILLNPITGRRFVNE", 
"SLSSKLSVQD", "SNLKKITLE", "SNPTAKLNLIWPATPIHIKKYE", "SQGKTLSVKQE", 
"SQLTNLFNEE", "SQRIASKNQLE", "SRFQEIVKE", "SRKLFAATVAKAKTIVWNGPPGVFE", 
"SSANRKIVKE", "STKNGTETKRSLE", "STPDTPSPLIAVNE", "STVAGFLVGSE", 
"STVLQFKE", "SVKLTKAVAE", "SVLAHL", "SYQKSQKSQKE", "SYVDKHPVVTFNQE", 
"TAGLTVGDPVLRTGKPLSVE", "TAIGPSGQLKGYLRPE", "TAKGNYPINAVTTMAE", 
"TAQGQFLNFNKLLE", "TARSTATGPSEAVWYGPPKAANLGGVAVSGLE", "TDPFKLSGAQVVD", 
"TEPLGTAGPLKLAE", "TFKLFNKYRPE", "TFRTTNTL", "TGGPISVPVGRE", 
"TGIVAQYAYVLGELE", "TGVIKPGMVVTFAPAGVTTE", "THINLKVSDGSSE", 
"TIGNPKYNVPDFE", "TIQDKSSAGAVVVANAKSLE", "TKAGVVKGKTLLE", 
"TKKSCCSGK", "TKNFTPEQISSMVLGKMKE", "TKTFSPQE", "TKYLSGIAKRLNKE", 
"TLKKFGEE", "TLKQLNASLADKSYIE", "TLKVVDPE", "TLRKVVKHFIDE", 
"TMKAVVIE", "TMWDTKKE", "TNPGTDVTVSSVE", "TQALLLAPIAPHFAE", 
"TQKGVIFYE", "TRLSLTHMVE", "TSGSTVNDPLANYE", "TSNFIKKVGYNPKTVPFVPISGWNGDNMIE", 
"TSSKKPKHPLE", "TTAMITDIATAPAE", "TTHIKFASDPGCAFTKSIGFE", 
"TTTGVHHLYRMVKE", "TVAASAVAAVFE", "TVAKSKNAE", "TVFAGQKP", 
"TVLRQALGE", "TVQVNLPVSLE", "TVSKMAYLDKTGE", "VAAIMQDPVMQSILQQAQQNPAALQE", 
"VAALAAENK", "VAKVVGANPAAIKQAIAANA", "VANPIMSKLYQAGGAPE", 
"VARVILTQVGSGPQETNE", "VATRAKQGELLE", "VDASGFRIPQQE", "VDSVLKHMKE", 
"VEGMRWAGNANE", "VFIDFTKE", "VFKFFGFTPE", "VFKFFGFTPEGVAE", 
"VFLNEHPE", "VFVATKE", "VGAKGVQLLSSYITEE", "VGASMTRSIQTLE", 
"VGKSVAVDSSE", "VGLKRVVTKAMSSR", "VGTMNVFFVFLNKVTGKKE", "VGVHVLPKILDE", 
"VHFVSNIDGTHIAE", "VIAGNVVTRE", "VIDTILALVKD", "VKILNGFAFVE", 
"VKVVLFNHSQRD", "VLANYLTSALSE", "VLAVQKKLIAKSNLAGKPVICATQMLE", 
"VLGPFAFRIGSVKE", "VLIKRGVKPE", "VLLLDVTPLSLGIE", "VLLVAVGRRPYIAGLGAE", 
"VLNPQIIKDVLE", "VLPRAVGSLTFDE", "VLVLRGTLE", "VLVVRGSKKGQE", 
"VLYTSKLSRAIQTANIALE", "VMSIGRTFEE", "VMTKNPVTGIKGITLKE", 
"VQNSTLAQLTSKLIPE", "VQSAVLGFPRIGPNRE", "VRVTPTKTE", "VSAAYKNSLE", 
"VSDVAQKAE", "VSGLQYIDLLLIHSPLE", "VSNPNIIFFRGTYAAVSPE", 
"VSNPPAYGAKIVAKLLETPE", "VSNRSTPSVVGFGPKNRYLGE", "VSSMPTLIFYKGGKE", 
"VSVVDLTVKLNKE", "VTAALRVTD", "VTPLVQNVTGDKE", "VTRVVGANPAAIKQAIASNV", 
"VTSSFFYRGNYTDFE", "VVALNDPFITND", "VVKILRE", "VVLPVDFIIAD", 
"VVLTHPADE", "VVNIGIGGSDLGPVMVTE", "VVTSASAPPENASE", "VVVITKNVSGQDVAAALE", 
"VYHNLKSLTKKRYGASAGNVGDE", "VYKIGGIGTVPVGRVE", "WAGLGKIDRE", 
"WFDIKAPSTFE", "WFRIYKIPDGKPE", "WGKFLTCVEVE", "WLFKLREE", 
"WMWNQLGNFLQE", "WSKLISE", "WSLTAPLGKALHDLS", "WTKIFKAIHE", 
"YAQLLAKRLSE", "YAQLLAKRLSERKAE", "YFATHITE", "YFATHITERE", 
"YFQLLNSALTE", "YGYSARVVDLIE", "YGYSTRVVD", "YGYSTRVVDLVE", 
"YIALVDQLIAKYSS", "YIASKKGSISAE", "YKDIPVPKPKANE", "YKPLFTE", 
"YLLKAIKE", "YLNLPEHIVPGTYIQE", "YNKIGDILSGRLKLRAE", "YQSKIIVFPRDGKAPE", 
"YQTQVLKNAKALE", "YQYLRSVVNE", "YRKVLPIVSVPE", "YRLSVLPDNVPIMSVE", 
"YSLLAWTNIPRKE", "YVAKVSARE", "YVNKGQDFHIAGE", "YVPSVIEPSFGIGRIIYSVFE", 
"YVQAAKNSIAAGADGVE"), class = "factor"), variable = structure(c(1L, 
1L, 1L, 1L, 1L, 1L), .Label = c("BiotinControl1_2", "BiotinControl2", 
"BiotinControl3", "BiotinTreatment1_2", "BiotinTreatment2", 
"BiotinTreatment3"), class = "factor"), value = c(3893050.501, 
900604.6087, 90008.14298, 656399.2021, 359937.85, 447089.3547 
)), .Names = c("id", "Sequence", "variable", "value"), row.names = c(NA, 
6L), class = "data.frame") 

現在是關於警告的內容。我相信這是我的代碼完全錯誤的東西。

1: In anova.lm(lm(value ~ variable, data = x)) : 
ANOVA F-tests on an essentially perfect fit are unreliable 
2: In anova.lm(lm(value ~ variable, data = x)) : 
ANOVA F-tests on an essentially perfect fit are unreliable 
3: In anova.lm(lm(value ~ variable, data = x)) : 
ANOVA F-tests on an essentially perfect fit are unreliable 
4: In anova.lm(lm(value ~ variable, data = x)) : 
ANOVA F-tests on an essentially perfect fit are unreliable 

,這是一個簡單的功能,我想在循環中使用:

aov.test <- summary(aov(tbl_reo$value_column ~ as.factor(tbl_reo$variable))) 

tbl_reo[,5] <- aov.test[[1]]$'Pr(>F)'[1] 

是否有任何人誰可以幫我嗎?只是要求最後一次,併爲這個小垃圾郵件抱歉。

回答

1

您可以使用ddplyplyr包例如:

ddply(tbl_reo,.(Sequence),transform,pv= anova(lm(value ~ variable))$"Pr(>F)"[1]) 
    id   Sequence   variable  value  pv 
1 75 AAAAGAAAVANQGKK BiotinControl1_2 3893050.50 0.9351210 
2 192 AAAAGAAAVANQGKK BiotinControl1_2 900604.61 0.9351210 
3 75 AAAAGAAAVANQGKK  BiotinControl2 2717893.32 0.9351210 
4 192 AAAAGAAAVANQGKK  BiotinControl2 741299.33 0.9351210 
5 75 AAAAGAAAVANQGKK BiotinTreatment1_2 3435216.40 0.9351210 
6 192 AAAAGAAAVANQGKK BiotinTreatment1_2 818936.89 0.9351210 
7 3770  AAFTKLDQVWGSE BiotinControl1_2 90008.14  NaN 
8 3770  AAFTKLDQVWGSE  BiotinControl2 87127.07  NaN 
9 3770  AAFTKLDQVWGSE BiotinTreatment1_2 85120.95  NaN 
10 934 AAIKFIKFINPKINDGE BiotinControl1_2 656399.20 0.1550903 
11 1012 AAIKFIKFINPKINDGE BiotinControl1_2 359937.85 0.1550903 
12 1970 AAIKFIKFINPKINDGE BiotinControl1_2 447089.35 0.1550903 
13 934 AAIKFIKFINPKINDGE  BiotinControl2 646758.14 0.1550903 
14 934 AAIKFIKFINPKINDGE BiotinTreatment1_2 1068384.55 0.1550903 
+0

爲什麼p值的序列完全一樣?每種情況下的值都不相同......這個NaN怎麼樣?我收到了關於警告的消息以及「有50條或更多的警告(使用警告()查看前50條)」 – Juanhijuan

+0

這些順序並不相同。你可以按順序計算它,所以你可以按照順序來計算相同的值。楠值我猜,因爲你沒有足夠的價值來計算它... – agstudy

+0

我必須信任你,因爲我不那麼好是這樣的統計。無論如何,這對我來說很奇怪,以獲得這樣的結果。 Thx爲您提供幫助。如果你有任何建議,我會很高興。我用edit()來檢查p值是否在「tbl_reo」中,但不存在。爲什麼? – Juanhijuan